-
Notifications
You must be signed in to change notification settings - Fork 90
/
exception.py
67 lines (43 loc) · 1.2 KB
/
exception.py
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
from helper.codetable import (
PAGE_OUT_OF_RANGE,
DATA_NOT_FOUND,
DATA_EXISTS,
VALIDATE_ERROR,
UNAUTHORIZED_ERROR,
TOKEN_EXPIRED,
ACCESS_EXPIRED,
CONNECT_TIMEOUT
)
class APIBaseError(Exception):
code: int
def __init__(self, msg, data=None):
self.msg = msg
self.data = data
class PageOutOfRange(APIBaseError):
code = PAGE_OUT_OF_RANGE
class DataExistsError(APIBaseError):
code = DATA_EXISTS
class DataNotFound(APIBaseError):
code = DATA_NOT_FOUND
class ValidateError(APIBaseError):
code = VALIDATE_ERROR
class UnauthorizedError(APIBaseError):
code = UNAUTHORIZED_ERROR
class TokenExpired(APIBaseError):
code = TOKEN_EXPIRED
class AccessExpired(APIBaseError):
code = ACCESS_EXPIRED
class RemoteApplyException(Exception):
def __init__(self, key, funcid, context, ret, exc):
self.key = key
self.funcid = funcid
self.context = context
self.ret = ret
self.exc = exc
class ConnectionTimeout(APIBaseError):
code = CONNECT_TIMEOUT
class ClientResponseError(Exception):
def __init__(self, code, msg, exc=None):
self.code = code
self.msg = msg
self.exc = exc