-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathexceptions.py
More file actions
72 lines (54 loc) · 1.55 KB
/
exceptions.py
File metadata and controls
72 lines (54 loc) · 1.55 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
class GitModelError(Exception):
"""A base exception for other gitmodel-related errors."""
pass
class ConfigurationError(GitModelError):
"""Raised during configuration errors"""
pass
class UnsupportedFormat(GitModelError):
"""
Raised when an unsupported serialization format is requested.
"""
pass
class FieldError(GitModelError):
"""
Raised when there is a configuration error with a ``Field``.
"""
pass
class DoesNotExist(GitModelError):
"""
Raised when the object in question can't be found.
"""
pass
class RepositoryError(GitModelError):
"""
Raises during an error while operating with the repository
"""
pass
class RepositoryNotFound(GitModelError):
"""
Raises when the repository doesn't exist
"""
class ValidationError(GitModelError):
"""
Raised when an invalid value is encountered
"""
def __init__(self, msg_or_code, field=None, **kwargs):
self.field = field
self.msg_or_code = msg_or_code
if self.field:
msg = self.field.get_error_message(msg_or_code,
default=msg_or_code,
**kwargs)
else:
msg = msg_or_code
super(ValidationError, self).__init__(msg)
class IntegrityError(GitModelError):
"""
Raised when a save results in duplicate values
"""
pass
class ModelNotFound(Exception):
"""
Raised during deserialization if the model class no longer exists
"""
pass