Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
angel-one
GitHub Repository: angel-one/smartapi-python
Path: blob/main/SmartApi/smartExceptions.py
410 views
1
class SmartAPIException(Exception):
2
3
def __init__(self, message, code=500):
4
"""Initialize the exception."""
5
super(SmartAPIException, self).__init__(message)
6
self.code = code
7
8
9
class GeneralException(SmartAPIException):
10
"""An unclassified, general error. Default code is 500."""
11
12
def __init__(self, message, code=500):
13
"""Initialize the exception."""
14
super(GeneralException, self).__init__(message, code)
15
16
17
class TokenException(SmartAPIException):
18
"""Represents all token and authentication related errors. Default code is 403."""
19
20
def __init__(self, message, code=403):
21
"""Initialize the exception."""
22
super(TokenException, self).__init__(message, code)
23
24
25
class PermissionException(SmartAPIException):
26
"""Represents permission denied exceptions for certain calls. Default code is 403."""
27
28
def __init__(self, message, code=403):
29
"""Initialize the exception."""
30
super(PermissionException, self).__init__(message, code)
31
32
33
class OrderException(SmartAPIException):
34
"""Represents all order placement and manipulation errors. Default code is 500."""
35
36
def __init__(self, message, code=500):
37
"""Initialize the exception."""
38
super(OrderException, self).__init__(message, code)
39
40
41
class InputException(SmartAPIException):
42
"""Represents user input errors such as missing and invalid parameters. Default code is 400."""
43
44
def __init__(self, message, code=400):
45
"""Initialize the exception."""
46
super(InputException, self).__init__(message, code)
47
48
49
class DataException(SmartAPIException):
50
"""Represents a bad response from the backend Order Management System (OMS). Default code is 502."""
51
52
def __init__(self, message, code=502):
53
"""Initialize the exception."""
54
super(DataException, self).__init__(message, code)
55
56
57
class NetworkException(SmartAPIException):
58
"""Represents a network issue between api and the backend Order Management System (OMS). Default code is 503."""
59
60
def __init__(self, message, code=503):
61
"""Initialize the exception."""
62
super(NetworkException, self).__init__(message, code)
63
64