File tree 1 file changed +8
-1
lines changed
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 1
1
# exceptions.py
2
2
3
+
3
4
class DataFogException (Exception ):
4
5
"""Base exception for DataFog SDK"""
6
+
5
7
def __init__ (self , message : str , status_code : int = None ):
6
8
self .message = message
7
9
self .status_code = status_code
8
10
super ().__init__ (self .message )
9
11
12
+
10
13
class BadRequestError (DataFogException ):
11
14
"""Exception raised for 400 Bad Request errors"""
15
+
12
16
def __init__ (self , message : str ):
13
17
super ().__init__ (message , status_code = 400 )
14
18
19
+
15
20
class UnprocessableEntityError (DataFogException ):
16
21
"""Exception raised for 422 Unprocessable Entity errors"""
22
+
17
23
def __init__ (self , message : str ):
18
24
super ().__init__ (message , status_code = 422 )
19
25
26
+
20
27
def raise_for_status_code (status_code : int , error_message : str ):
21
28
"""Raise the appropriate exception based on the status code"""
22
29
if status_code == 400 :
23
30
raise BadRequestError (error_message )
24
31
elif status_code == 422 :
25
- raise UnprocessableEntityError (error_message )
32
+ raise UnprocessableEntityError (error_message )
You can’t perform that action at this time.
0 commit comments