Files
bigwo/exceptions.py
2026-03-02 17:38:28 +08:00

35 lines
904 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""异常类型定义"""
from typing import Optional
class ParseError(Exception):
"""文件解析错误:文件损坏、格式不支持、编码无法识别"""
def __init__(self, file_name: str, reason: str):
self.file_name = file_name
self.reason = reason
super().__init__(f"解析失败 [{file_name}]: {reason}")
class UnsupportedFormatError(ParseError):
"""不支持的文件格式"""
def __init__(self, file_name: str, extension: str):
self.extension = extension
super().__init__(file_name, f"不支持的文件格式: {extension}")
class ApiError(Exception):
"""DeepSeek API 调用错误"""
def __init__(self, message: str, status_code: Optional[int] = None):
self.status_code = status_code
super().__init__(message)
class RateLimitError(ApiError):
"""API 速率限制错误HTTP 429"""
pass