-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.py
More file actions
80 lines (51 loc) · 2.1 KB
/
Copy patherrors.py
File metadata and controls
80 lines (51 loc) · 2.1 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
from typing import Any, List
class MaskNotValidError(Exception):
"""Exception raised for errors in the mask structure."""
def __init__(self, message: str) -> None:
self.message = message
class SquareNotValidError(Exception):
"""Raised for errors in the square structure."""
def __init__(self, message: str) -> None:
self.message = message
class InputLengthError(Exception):
"""Raised for errors in the input's length."""
def __init__(self, length: int) -> None:
self.length = length
def __str__(self):
return "Input's length must be a multiple of {0}".format(self.length)
class EmptyKeyError(Exception):
"""Raised if the key is empty."""
def __str__(self):
return "Key must be not empty"
class CharNotAllowedError(Exception):
"""Raised when the char is not allowed for input."""
def __init__(self, char: str) -> None:
self.char = char
def __str__(self):
return "Char '{0}' is not allowed".format(self.char)
class HexNotValidError(Exception):
"""Raised if read hex is not valid."""
def __init__(self, hex: str) -> None:
self.hex = hex
def __str__(self):
return "Hex '{0}' is not valid".format(self.hex)
class ValueNotInListError(Exception):
"""Raised if the value is not in the list of allowed values."""
def __init__(self, name: str, value: Any, allowed: List[Any]) -> None:
self.name = name
self.value = value
self.allowed = allowed
def __str__(self):
return "{0} value ({1}) is not allowed. Allowed values: {2}".format(
self.name, self.value, self.allowed)
class ValueNotInRangeError(Exception):
"""Raised if the value is not in the given range."""
def __init__(self, value_name: str, value: int, min_value: int,
max_value: int) -> None:
self.name = value_name
self.value = value
self.min = min_value
self.max = max_value
def __str__(self):
return "{0} value ({1}) is not in range ({2} - {3}).".format(
self.name, self.value, self.min, self.max)