forked from symphonyfintech/xts-pythonclient-api-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Exception.py
81 lines (55 loc) · 2.97 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import requests
import json
from requests import exceptions
from requests.exceptions import HTTPError
from requests import ConnectTimeout, HTTPError, Timeout, ConnectionError
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Here we have declared all the exception and responses
If there is any exception occurred we have this code to convey the messages
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
class XTSException(Exception):
"""
Base exception class representing a XTS client exception.
Every specific XTS client exception is a subclass of this
and exposes two instance variables `.code` (HTTP error code)
and `.message` (error text).
"""
def __init__(self, message, code=500):
"""Initialize the exception."""
super(XTSException, self).__init__(message)
self.code = code
class XTSGeneralException(XTSException):
"""An unclassified, general error. Default code is 500."""
def __init__(self, message, code=500):
"""Initialize the exception."""
super(XTSGeneralException, self).__init__(message, code)
class XTSTokenException(XTSException):
"""Represents all token and authentication related errors. Default code is 400."""
def __init__(self, message, code=400):
"""Initialize the exception."""
super(XTSTokenException, self).__init__(message, code)
class XTSPermissionException(XTSException):
"""Represents permission denied exceptions for certain calls. Default code is 400."""
def __init__(self, message, code=400):
"""Initialize the exception."""
super(XTSPermissionException, self).__init__(message, code)
class XTSOrderException(XTSException):
"""Represents all order placement and manipulation errors. Default code is 500."""
def __init__(self, message, code=400):
"""Initialize the exception."""
super(XTSOrderException, self).__init__(message, code)
class XTSInputException(XTSException):
"""Represents user input errors such as missing and invalid parameters. Default code is 400."""
def __init__(self, message, code=400):
"""Initialize the exception."""
super(XTSInputException, self).__init__(message, code)
class XTSDataException(XTSException):
"""Represents a bad response from the backend Order Management System (OMS). Default code is 500."""
def __init__(self, message, code=500):
"""Initialize the exception."""
super(XTSDataException, self).__init__(message, code)
class XTSNetworkException(XTSException):
"""Represents a network issue between XTS and the backend Order Management System (OMS). Default code is 500."""
def __init__(self, message, code=500):
"""Initialize the exception."""
super(XTSNetworkException, self).__init__(message, code)