-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors.py
61 lines (44 loc) · 1.65 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
__author__ = 'Purg'
### Configuration object errors ###############################################
class ConfigurationError (Exception):
"""
Base class for errors dealing with Configuration objects.
"""
pass
class ConfigurationInvalidItemKeyTypeError (ConfigurationError):
"""
Exception for when an invalid item key for option access is provided.
"""
def __init__(self):
super(ConfigurationInvalidItemKeyTypeError, self).__init__(
"Invalid access key provided must be of type str, "
"ConfigurationOption or Configuration."
)
class ConfigurationKeyNotPresentError (ConfigurationError):
""" Exception for when a given key name is not present in a configuration
"""
def __init__(self, key):
super(ConfigurationKeyNotPresentError, self).__init__(
"No such key '%s' in this configuration"
% key
)
class ConfigurationDotNotationSetError (ConfigurationError):
""" Exception for when setting a new configuration options via dot notation
"""
def __init__(self, key):
super(ConfigurationDotNotationSetError, self).__init__(
"Attempted to option to key '%s'. This is already reserved in this "
"configuration class/instance."
% key
)
### ConfigurationOption object errors #########################################
class ConfigurationOptionError (ConfigurationError):
"""
Base exception class for ConfigurationOption errors.
"""
pass
class ConfigurationOptionDoesNotExistError (ConfigurationOptionError):
"""
Exception for when an option does not exist
"""
pass