forked from aws-powertools/powertools-lambda-python
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexceptions.py
45 lines (30 loc) · 1021 Bytes
/
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
from http import HTTPStatus
class ServiceError(Exception):
"""Service Error"""
def __init__(self, status_code: int, msg: str):
"""
Parameters
----------
status_code: int
Http status code
msg: str
Error message
"""
self.status_code = status_code
self.msg = msg
class BadRequestError(ServiceError):
"""Bad Request Error"""
def __init__(self, msg: str):
super().__init__(HTTPStatus.BAD_REQUEST, msg)
class UnauthorizedError(ServiceError):
"""Unauthorized Error"""
def __init__(self, msg: str):
super().__init__(HTTPStatus.UNAUTHORIZED, msg)
class NotFoundError(ServiceError):
"""Not Found Error"""
def __init__(self, msg: str = "Not found"):
super().__init__(HTTPStatus.NOT_FOUND, msg)
class InternalServerError(ServiceError):
"""Internal Server Error"""
def __init__(self, message: str):
super().__init__(HTTPStatus.INTERNAL_SERVER_ERROR, message)