-
Notifications
You must be signed in to change notification settings - Fork 1
/
exception.py
49 lines (38 loc) · 2.25 KB
/
exception.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
import sys
class Error:
def __init__(self, message, line, command):
print()
if command != None:
print(f"> {command}")
print(f"Ошибка : на строке {line} : {message}")
sys.exit(1)
class BlockNotFound(Error):
def __init__(self, name):
super().__init__(f"Не удалось найти блок под номером {name}", None, None)
class IncorrectValue(Error):
def __init__(self, line, command, trueType):
super().__init__(f"Некорректное значение, ячейка может хранить только {trueType}", line, command)
class CellNotFound(Error):
def __init__(self, line, command, name):
super().__init__(f"Не удалось найти ячейку под номером {name}", line, command)
class DifferentTypes(Error):
def __init__(self, line, command):
super().__init__(f"У ячеек разные типы данных", line, command)
class NoString(Error):
def __init__(self, line, command):
super().__init__(f"В данной команде нельзя использовать ячейку с типом string", line, command)
class TypeIsNotString(Error):
def __init__(self, line, command):
super().__init__(f"Тип ячейки должен быть string", line, command)
class StringAndInt(Error):
def __init__(self, line, command):
super().__init__(f"У первой ячейки должен быть тип string, а у второй int", line, command)
class InvalidSyntax(Error):
def __init__(self, line, command):
super().__init__(f"Не корректный синтаксис", line, command)
class IncorrectCellName(Error):
def __init__(self, line, command, name):
super().__init__(f"Имя {name} для ячейки не корректное! имя должно быть отрицательным числом от -1", line, command)
class IncorrectDataType(Error):
def __init__(self, line, command, name):
super().__init__(f"Тип {name} для ячейки не корректное! Тип данных должен быть одним из: 0 - int, 1 - string, 2 - float", line, command)