-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathexceptions.py
More file actions
120 lines (76 loc) · 3.11 KB
/
exceptions.py
File metadata and controls
120 lines (76 loc) · 3.11 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
from typing import Type
from print_service.settings import get_settings
settings = get_settings()
class PrintAPIError(Exception):
eng: str
ru: str
def __init__(self, eng: str, ru: str) -> None:
self.eng = eng
self.ru = ru
super().__init__(eng)
class ObjectNotFound(PrintAPIError):
def __init__(self, obj: type, obj_id_or_name: int | str):
super().__init__(
f"Object {obj.__name__} {obj_id_or_name=} not found",
f"Объект {obj.__name__} с идентификатором {obj_id_or_name} не найден",
)
class AlreadyExists(PrintAPIError):
def __init__(self, obj: type, obj_id_or_name: int | str):
super().__init__(
f"Object {obj.__name__}, {obj_id_or_name=} already exists",
f"Объект {obj.__name__} с идентификатором {obj_id_or_name=} уже существует",
)
class TerminalTokenNotFound(ObjectNotFound):
def __init__(self, token_id: int | str):
super().__init__(type(self), token_id)
class TerminalQRNotFound(ObjectNotFound):
def __init__(self, qr_id: int | str):
super().__init__(type(self), qr_id)
class PINNotFound(ObjectNotFound):
def __init__(self, pin: str):
self.pin = pin
super().__init__(type(self), pin)
class UserNotFound(ObjectNotFound):
def __init__(self, user_id: int | str):
super().__init__(type(self), user_id)
class FileNotFound(ObjectNotFound):
def __init__(self, file_id: int | str):
super().__init__(type(self), file_id)
class TooManyPages(Exception):
def __init__(self):
super().__init__(f'Content too large, count of page: {settings.MAX_PAGE_COUNT} is allowed')
class TooLargeSize(Exception):
def __init__(self):
super().__init__(f'Content too large, {settings.MAX_SIZE} bytes allowed')
class InvalidPageRequest(Exception):
def __init__(self):
super().__init__(f'Invalid format')
class UnionStudentDuplicate(Exception):
def __init__(self):
super().__init__('Duplicates by union_numbers or student_numbers')
class NotInUnion(Exception):
def __init__(self):
super().__init__(f'User is not found in trade union list')
class PINGenerateError(Exception):
def __init__(self):
super().__init__(f'Can not generate PIN. Too many users?')
class FileIsNotReceived(Exception):
def __init__(self):
super().__init__(f'No file was recieved')
class InvalidType(Exception):
def __init__(self, content_type: str):
super().__init__(
f'Only {", ".join(settings.CONTENT_TYPES)} files allowed, but {content_type} was recieved'
)
class AlreadyUploaded(Exception):
def __init__(self):
super().__init__(f'File has been already uploaded')
class IsCorrupted(Exception):
def __init__(self):
super().__init__(f'File is corrupted')
class IsNotUploaded(Exception):
def __init__(self):
super().__init__(f'File has not been uploaded yet')
class UnprocessableFileInstance(Exception):
def __init__(self):
super().__init__(f'Unprocessable file instance')