-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexceptions.py
62 lines (47 loc) · 1.77 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
__all__ = [
"EelExcSysTypeError",
"EelExcInvalidOperation",
"EelExcNotAnEelRepr",
"EelExcTypeError",
"EelExcCommandNotFound"
]
class EelExcBaseException(Exception):
def __init__(self, message: str, name: str, exit_code: int = 1) -> None:
self.name = name
self.exit_code = exit_code
super().__init__(message)
# System Exception
class EelExcSystemException(EelExcBaseException):
def __init__(self, message: str | None = None, name: str | None = None):
if name is None:
name = ""
else:
name = f"<{name}>"
if message is None:
message = "Unknown error has occurred"
super().__init__(message, f"InternalError{name}", 120)
class EelExcSysTypeError(EelExcSystemException):
def __init__(self, message: str | None = None):
super().__init__(message, "TypeError")
# Generic Exception
class EelWhenEvaluating(EelExcBaseException):
def __init__(self, message: str, exit_code: int):
super().__init__(message, " when evaluating", exit_code)
class EelExcCommandNotFound(EelExcBaseException):
def __init__(self, message: str):
super().__init__(message, "CommandNotFound", 127)
class EelExcFileError(EelExcBaseException):
def __init__(self, message: str):
super().__init__(message, "FileError", 1)
class EelExcArgumentError(EelExcBaseException):
def __init__(self, message: str):
super().__init__(message, "ArgumentError", 2)
class EelExcInvalidOperation(EelExcBaseException):
def __init__(self, message: str):
super().__init__(message, "InvalidOperationError", 3)
class EelExcNotAnEelRepr(EelExcBaseException):
def __init__(self, message: str):
super().__init__(message, "NotAnEelRepr", 4)
class EelExcTypeError(EelExcBaseException):
def __init__(self, message: str):
super().__init__(message, "TypeError", 5)