File size: 484 Bytes
01d5a5d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from typing import Any


class ErrorCodes:
    SUCCESS = 0
    BAD_REQUEST = 400
    UNAUTHORIZED = 401
    FORBIDDEN = 403
    NOT_FOUND = 404
    INTERNAL_ERROR = 500
    CONFIGURATION_ERROR = 501
    PATH_NOT_FOUND = 10404


class APIError(Exception):
    def __init__(
        self, message: str, code: int = ErrorCodes.INTERNAL_ERROR, data: Any = None
    ):
        self.message = message
        self.code = code
        self.data = data
        super().__init__(self.message)