-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptions.py
More file actions
43 lines (37 loc) · 950 Bytes
/
exceptions.py
File metadata and controls
43 lines (37 loc) · 950 Bytes
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
from enum import IntEnum, auto
from typing import (
Optional
)
class ErrorCode(IntEnum):
"""For each error there is an
error code so the frontend
developer can clearfiy the
error"""
NO_EVENT_FOUND = auto()
INVAILD_DATA = auto()
WRONG_DATA = auto()
USER_ALREADY_IN_PARTY = auto()
PARTY_NOT_FOUND = auto()
CONTROLLER_NOT_FOUND = auto()
EVENT_NOT_FOUND = auto()
NOT_AUTH = auto()
NOT_IN_PARTY = auto()
class ExceptionAbstract(Exception):
"""Base abstraction to the errors."""
def __init__(
self,
error_code: int,
message: Optional[str]
):
self.error_code = error_code
self.message = message
super().__init__(message)
def json_error(self):
return {
"code": self.error_code,
"errors": [
self.message
]
}
class GeneralException(ExceptionAbstract):
pass