-
Notifications
You must be signed in to change notification settings - Fork 488
/
Copy pathexceptions.py
80 lines (53 loc) · 2.51 KB
/
exceptions.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
# -*- coding: utf-8 -*-
"""
exceptions.py
Exceptions raised by the Kite Connect client.
:copyright: (c) 2021 by Zerodha Technology.
:license: see LICENSE for details.
"""
class KiteException(Exception):
"""
Base exception class representing a Kite client exception.
Every specific Kite 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(KiteException, self).__init__(message)
self.code = code
class GeneralException(KiteException):
"""An unclassified, general error. Default code is 500."""
def __init__(self, message, code=500):
"""Initialize the exception."""
super(GeneralException, self).__init__(message, code)
class TokenException(KiteException):
"""Represents all token and authentication related errors. Default code is 403."""
def __init__(self, message, code=403):
"""Initialize the exception."""
super(TokenException, self).__init__(message, code)
class PermissionException(KiteException):
"""Represents permission denied exceptions for certain calls. Default code is 403."""
def __init__(self, message, code=403):
"""Initialize the exception."""
super(PermissionException, self).__init__(message, code)
class OrderException(KiteException):
"""Represents all order placement and manipulation errors. Default code is 500."""
def __init__(self, message, code=500):
"""Initialize the exception."""
super(OrderException, self).__init__(message, code)
class InputException(KiteException):
"""Represents user input errors such as missing and invalid parameters. Default code is 400."""
def __init__(self, message, code=400):
"""Initialize the exception."""
super(InputException, self).__init__(message, code)
class DataException(KiteException):
"""Represents a bad response from the backend Order Management System (OMS). Default code is 502."""
def __init__(self, message, code=502):
"""Initialize the exception."""
super(DataException, self).__init__(message, code)
class NetworkException(KiteException):
"""Represents a network issue between Kite and the backend Order Management System (OMS). Default code is 503."""
def __init__(self, message, code=503):
"""Initialize the exception."""
super(NetworkException, self).__init__(message, code)