2023-11-05 16:29:11 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
2023-11-08 00:21:17 +08:00
|
|
|
from typing import *
|
|
|
|
|
2023-11-05 16:29:11 +08:00
|
|
|
__all__ = (
|
|
|
|
'SdkError',
|
|
|
|
'InitError',
|
2023-11-08 00:21:17 +08:00
|
|
|
'TransportError',
|
|
|
|
'ResponseError',
|
2023-11-05 16:29:11 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class SdkError(Exception):
|
|
|
|
"""SDK错误的基类"""
|
|
|
|
|
|
|
|
|
|
|
|
class InitError(SdkError):
|
|
|
|
"""初始化失败"""
|
2023-11-08 00:21:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
class TransportError(SdkError):
|
|
|
|
"""通信错误"""
|
|
|
|
|
|
|
|
|
|
|
|
class ResponseError(SdkError):
|
|
|
|
"""响应代码错误"""
|
|
|
|
def __init__(self, code: int, msg: str, data: Optional[dict] = None):
|
|
|
|
super().__init__(f'code={code}, msg={msg}, data={data}')
|
|
|
|
self.code = code
|
|
|
|
self.msg = msg
|
|
|
|
self.data = data
|