-
Notifications
You must be signed in to change notification settings - Fork 2
/
errors.py
86 lines (50 loc) · 2.53 KB
/
errors.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
class GeneralError(Exception):
"""Base class for other exceptions"""
def __init__(self, message="An error occurred"):
self.message = message
super().__init__(self.message)
class DatasetParquetNameError(GeneralError):
"""Raised when the dataset name does not match the expected pattern"""
def __init__(self, message="Dataset name does not match the expected pattern"):
super().__init__(message)
class InvalidOutputError(GeneralError):
"""Raised when the output of a function is invalid"""
def __init__(self, message="Invalid output"):
super().__init__(message)
class MissingTranslationError(GeneralError, ):
"""Raised when the translation is missing"""
def __init__(self, message="Translation is missing", i: int = None):
super().__init__(f"{message} at index {i}" if i is not None else message)
class ReachedMaxRetriesError(GeneralError):
"""Raised when the maximum number of retries is reached"""
def __init__(self, message="Maximum number of retries reached"):
super().__init__(message)
class TranslationError(GeneralError):
"""Raised when a general error occurs during translation"""
def __init__(self, message="General error occurred during translation"):
message = f"[TranslationError] {message}"
super().__init__(message)
class EmptyContentError(TranslationError):
"""Raised when the content is empty"""
def __init__(self, message="Content is empty"):
super().__init__(message)
class EmptyOutputError(TranslationError):
"""Raised when the output is empty"""
def __init__(self, message="Output is empty"):
super().__init__(message)
class DelimiterAlreadyExistsError(TranslationError):
"""Raised when the delimiter already exists"""
def __init__(self, message="Delimiter already exists"):
super().__init__(message)
class MaxChunkSizeExceededError(TranslationError):
"""Raised when the maximum chunk size is exceeded"""
def __init__(self, message="Maximum chunk size exceeded"):
super().__init__(message)
class TranslateIOMismatchError(TranslationError):
"""Raised when the input and output count of the translation does not match"""
def __init__(self, message="Input and output count of the translation does not match"):
super().__init__(message)
class CannotSplitIntoChunksError(TranslationError):
"""Raised when the content cannot be split into chunks"""
def __init__(self, message="Cannot split content into chunks"):
super().__init__(message)