@@ -44,15 +44,43 @@ def __init__(self, file_format, code=400, json=None):
44
44
)
45
45
super (BaseUnsupportedError , self ).__init__ (message , code , json )
46
46
47
+
47
48
class AuthError (APIError ):
49
+ """
50
+ Authorization Error. This is for any case that user
51
+ has valid authentication but is unauthorized to access
52
+ particular resources
53
+
54
+ This is deprecated, should use AuthZError explicitly
55
+ """
48
56
def __init__ (self , message = None , code = 403 , json = None ):
49
57
if json is None :
50
58
json = {}
51
- auth_message = "You don't have access to this data "
59
+ auth_message = "You don't have access to this resource "
52
60
if message is not None :
53
61
auth_message += ': {}' .format (message )
54
62
super (AuthError , self ).__init__ (auth_message , code , json )
55
63
64
+
65
+ class AuthZError (AuthError ):
66
+ """
67
+ Authorization Error. This is for any case that user
68
+ has valid authentication but is unauthorized to access
69
+ particular resources
70
+ """
71
+ pass
72
+
73
+ class AuthNError (APIError ):
74
+ """
75
+ Authentication Error. This is for any case that user
76
+ is not authenticated or authenticated incorrectly
77
+ """
78
+ def __init__ (self , message = None , code = 401 , json = None ):
79
+ if message is not None :
80
+ message = "Authentication Error: {}" .format (message )
81
+ super (AuthNError , self ).__init__ (message , code , json )
82
+
83
+
56
84
class InvalidTokenError (AuthError ):
57
85
def __init__ (self ):
58
86
self .message = (
@@ -61,25 +89,25 @@ def __init__(self):
61
89
)
62
90
self .code = 403
63
91
92
+
64
93
class InternalError (APIError ):
65
94
def __init__ (self , message = None , code = 500 ):
66
95
self .message = "Internal server error"
67
96
if message :
68
97
self .message += ': {}' .format (message )
69
98
self .code = code
70
99
71
- class NotFoundError (APIError ):
72
- def __init__ (self , message ):
73
- super (NotFoundError , self ).__init__ (message , 404 , None )
74
-
75
100
76
101
class ServiceUnavailableError (APIError ):
77
102
def __init__ (self , message , code = 503 ):
78
103
self .message = message
79
104
self .code = code
105
+
106
+
80
107
class ParsingError (Exception ):
81
108
pass
82
109
110
+
83
111
class SchemaError (Exception ):
84
112
def __init__ (self , message , e = None ):
85
113
if e :
0 commit comments