2019-06-10 21:24:35 +00:00
|
|
|
class APIError(Exception):
|
2021-01-05 16:22:39 +00:00
|
|
|
def __init__(self, msg, code=500, subcode=0, error_data=None, **_):
|
2019-06-10 21:24:35 +00:00
|
|
|
super(APIError, self).__init__()
|
|
|
|
self._msg = msg
|
|
|
|
self._code = code
|
|
|
|
self._subcode = subcode
|
2021-01-05 16:22:39 +00:00
|
|
|
self._error_data = error_data or {}
|
2019-06-10 21:24:35 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def msg(self):
|
|
|
|
return self._msg
|
|
|
|
|
|
|
|
@property
|
|
|
|
def code(self):
|
|
|
|
return self._code
|
|
|
|
|
|
|
|
@property
|
|
|
|
def subcode(self):
|
|
|
|
return self._subcode
|
|
|
|
|
2021-01-05 16:22:39 +00:00
|
|
|
@property
|
|
|
|
def error_data(self):
|
|
|
|
return self._error_data
|
|
|
|
|
2019-06-10 21:24:35 +00:00
|
|
|
def __str__(self):
|
|
|
|
return self.msg
|