File size: 3,428 Bytes
b4f2238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
"""
统一异常处理模块
定义业务异常和全局异常处理器
"""

from __future__ import annotations

from typing import Any

# 基础异常
from .base import BusinessError, BusinessException

# 群聊异常
from .chat import (
    ChatCreationException,
    ChatProviderException,
    ConfigurationException,
    MessageSendException,
    OwnerConfigException,
    OwnerNetworkException,
    OwnerNotFoundException,
    OwnerPermissionException,
    OwnerRetryException,
    OwnerSettingException,
    OwnerTimeoutException,
    OwnerValidationException,
    UnsupportedPlatformException,
    owner_config_error,
    owner_network_error,
    owner_not_found_error,
    owner_permission_error,
    owner_retry_error,
    owner_timeout_error,
    owner_validation_error,
)

# 通用异常
from .common import (
    AuthenticationError,
    ConflictError,
    ForbiddenError,
    NotFoundError,
    PermissionDenied,
    RateLimitError,
    UnauthorizedError,
    ValidationException,
)

# 外部服务异常
from .external import (
    APIError,
    AutoTokenAcquisitionError,
    CaptchaRecognitionError,
    ExternalServiceError,
    LoginFailedError,
    NetworkError,
    NoAvailableAccountError,
    RecognitionTimeoutError,
    ServiceUnavailableError,
    TokenAcquisitionTimeoutError,
    TokenError,
)


def __getattr__(name: str) -> object:
    if name == "AutomationExceptions":
        import warnings

        warnings.warn(
            "AutomationExceptions is deprecated, use direct exception instantiation",
            DeprecationWarning,
            stacklevel=2,
        )
        from .automation_factory import AutomationExceptions as _AutomationExceptions

        return _AutomationExceptions
    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")


# 异常处理器 - 延迟导入避免 Django 配置问题
def register_exception_handlers(*args: Any, **kwargs: Any) -> None:
    """延迟导入异常处理器"""
    from .handlers import register_exception_handlers as _register

    return _register(*args, **kwargs)


__all__ = [
    # 基础异常
    "BusinessException",
    "BusinessError",
    # 通用异常
    "ValidationException",
    "PermissionDenied",
    "NotFoundError",
    "ConflictError",
    "AuthenticationError",
    "RateLimitError",
    "ForbiddenError",
    "UnauthorizedError",
    # 外部服务异常
    "ExternalServiceError",
    "ServiceUnavailableError",
    "RecognitionTimeoutError",
    "TokenError",
    "APIError",
    "NetworkError",
    "AutoTokenAcquisitionError",
    "LoginFailedError",
    "NoAvailableAccountError",
    "TokenAcquisitionTimeoutError",
    "CaptchaRecognitionError",
    # 群聊异常
    "ChatProviderException",
    "UnsupportedPlatformException",
    "ChatCreationException",
    "MessageSendException",
    "ConfigurationException",
    "OwnerSettingException",
    "OwnerPermissionException",
    "OwnerNotFoundException",
    "OwnerValidationException",
    "OwnerRetryException",
    "OwnerTimeoutException",
    "OwnerNetworkException",
    "OwnerConfigException",
    # 快捷构造函数
    "owner_permission_error",
    "owner_not_found_error",
    "owner_validation_error",
    "owner_retry_error",
    "owner_timeout_error",
    "owner_network_error",
    "owner_config_error",
    # Automation 异常工厂
    "AutomationExceptions",
    # 异常处理器
    "register_exception_handlers",
]