PamGram/modules/apihelper/error.py
omg-xtao b8c30768a6
️ 导入抽卡记录仅按 id 查找重复
Co-authored-by: 洛水居室 <luoshuijs@outlook.com>
2022-10-09 12:43:11 +08:00

50 lines
1.1 KiB
Python

from typing import Mapping, Any, Optional
class APIHelperException(Exception):
pass
class GachaLogException(APIHelperException):
pass
class GachaLogAccountNotFound(GachaLogException):
pass
class NetworkException(APIHelperException):
pass
class TimedOut(APIHelperException):
pass
class ResponseException(APIHelperException):
code: int = 0
message: str = ""
def __init__(self, response: Optional[Mapping[str, Any]] = None, message: Optional[str] = None) -> None:
if response is None:
self.message = message
_message = message
else:
self.code = response.get("retcode", self.code)
self.message = response.get("message", "")
_message = f"[{self.code}] {self.message}"
super().__init__(_message)
class DataNotFoundError(ResponseException):
def __init__(self):
message = "response data not find"
super().__init__(message=message)
class ReturnCodeError(ResponseException):
def __init__(self):
message = "response return code error"
super().__init__(message=message)