Skip to content

Commit 1154527

Browse files
Sid MohanSid Mohan
Sid Mohan
authored and
Sid Mohan
committed
pre-commit
1 parent ed0e0d1 commit 1154527

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

datafog/exceptions.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
# exceptions.py
22

3+
34
class DataFogException(Exception):
45
"""Base exception for DataFog SDK"""
6+
57
def __init__(self, message: str, status_code: int = None):
68
self.message = message
79
self.status_code = status_code
810
super().__init__(self.message)
911

12+
1013
class BadRequestError(DataFogException):
1114
"""Exception raised for 400 Bad Request errors"""
15+
1216
def __init__(self, message: str):
1317
super().__init__(message, status_code=400)
1418

19+
1520
class UnprocessableEntityError(DataFogException):
1621
"""Exception raised for 422 Unprocessable Entity errors"""
22+
1723
def __init__(self, message: str):
1824
super().__init__(message, status_code=422)
1925

26+
2027
def raise_for_status_code(status_code: int, error_message: str):
2128
"""Raise the appropriate exception based on the status code"""
2229
if status_code == 400:
2330
raise BadRequestError(error_message)
2431
elif status_code == 422:
25-
raise UnprocessableEntityError(error_message)
32+
raise UnprocessableEntityError(error_message)

0 commit comments

Comments
 (0)