forked from CenterForOpenScience/modular-file-renderer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptions.py
More file actions
66 lines (42 loc) · 2.2 KB
/
exceptions.py
File metadata and controls
66 lines (42 loc) · 2.2 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
from mfr.core.exceptions import RendererError
class TabularRendererError(RendererError):
def __init__(self, message, *args, **kwargs):
super().__init__(message, *args, renderer_class='tabular', **kwargs)
class MissingRequirementsError(TabularRendererError):
__TYPE = 'tabular_missing_requirements'
def __init__(self, message, *args, code: int = 500, function_preference: str = '', **kwargs):
super().__init__(message, *args, code=code, **kwargs)
self.function_preference = function_preference
self.attr_stack.append([self.__TYPE, {'function_preference': self.function_preference}])
class EmptyTableError(TabularRendererError):
__TYPE = 'tabular_empty_table'
def __init__(self, message, *args, code: int = 400, **kwargs):
super().__init__(message, *args, code=code, **kwargs)
self.attr_stack.append([self.__TYPE, {}])
class TableTooBigError(TabularRendererError):
__TYPE = 'tabular_table_too_big'
def __init__(self, message, *args, code: int = 400, nbr_cols: int = 0, nbr_rows: int = 0, **kwargs):
super().__init__(message, *args, code=code, **kwargs)
self.nbr_cols = nbr_cols
self.nbr_rows = nbr_rows
self.attr_stack.append([self.__TYPE, {
'nbr_cols': self.nbr_cols,
'nbr_rows': self.nbr_rows
}])
class UnexpectedFormattingError(TabularRendererError):
__TYPE = 'tabular_unexpected_formatting'
def __init__(self, message, *args, code: int = 500, formatting_function: str = '', **kwargs):
super().__init__(message, *args, code=code, **kwargs)
self.formatting_function = formatting_function
self.attr_stack.append([self.__TYPE, {'formatting_function': self.formatting_function}])
class FileTooLargeError(TabularRendererError):
__TYPE = 'tabular_file_too_large'
def __init__(self, message, *args, code: int = 400, file_size: int = None, max_size: int = None,
**kwargs):
super().__init__(message, *args, code=code, **kwargs)
self.file_size = file_size
self.max_size = max_size
self.attr_stack.append([self.__TYPE, {
'file_size': self.file_size,
'max_size': self.max_size
}])