Repository navigation
Expand file tree
/
Copy patherrors.py
More file actions
89 lines (80 loc) · 2.34 KB
/
Copy patherrors.py
File metadata and controls
89 lines (80 loc) · 2.34 KB
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
error_hierarchy = {
'BaseError': {
'ExchangeError': {
'AuthenticationError': {
'PermissionDenied': {},
'AccountSuspended': {},
},
'ArgumentsRequired': {},
'BadRequest': {
'BadSymbol': {},
},
'BadResponse': {
'NullResponse': {},
},
'InsufficientFunds': {},
'InvalidAddress': {
'AddressPending': {},
},
'InvalidOrder': {
'OrderNotFound': {},
'OrderNotCached': {},
'CancelPending': {},
'OrderImmediatelyFillable': {},
'OrderNotFillable': {},
'DuplicateOrderId': {},
},
'NotSupported': {},
},
'NetworkError': {
'DDoSProtection': {
'RateLimitExceeded': {},
},
'ExchangeNotAvailable': {
'OnMaintenance': {},
},
'InvalidNonce': {},
'RequestTimeout': {},
},
},
}
ExchangeError = Exception
AuthenticationError = Exception
PermissionDenied = Exception
AccountSuspended = Exception
ArgumentsRequired = Exception
BadRequest = Exception
BadSymbol = Exception
BadResponse = Exception
NullResponse = Exception
InsufficientFunds = Exception
InvalidAddress = Exception
AddressPending = Exception
InvalidOrder = Exception
OrderNotFound = Exception
OrderNotCached = Exception
CancelPending = Exception
OrderImmediatelyFillable = Exception
OrderNotFillable = Exception
DuplicateOrderId = Exception
NotSupported = Exception
NetworkError = Exception
DDoSProtection = Exception
RateLimitExceeded = Exception
ExchangeNotAvailable = Exception
OnMaintenance = Exception
InvalidNonce = Exception
RequestTimeout = Exception
# -----------------------------------------------------------------------------
__all__ = []
def error_factory(dictionary, super_class):
for key in dictionary:
__all__.append(key)
error_class = type(key, (super_class,), {})
globals()[key] = error_class
error_factory(dictionary[key], error_class)
class BaseError(Exception):
def __init__(self, message):
super(BaseError, self).__init__(message)
pass
error_factory(error_hierarchy['BaseError'], BaseError)