forked from openedx/openedx-events
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexceptions.py
69 lines (55 loc) · 1.97 KB
/
exceptions.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
"""
Custom exceptions thrown by Open edX events tooling.
"""
class OpenEdxEventException(Exception):
"""
Base class for Open edX Events exceptions.
"""
def __init__(self, message=""):
"""
Init method for OpenEdxEventException base class.
Arguments:
message (str): message describing why the exception was raised.
"""
super().__init__()
self.message = message
def __str__(self):
"""
Show string representation of OpenEdxEventException using its message.
"""
return self.message
class InstantiationError(OpenEdxEventException):
"""
Describes errors that occur while instantiating events.
This exception is raised when there's an error instantiating an Open edX
event, it can be that a required argument for the event definition is
missing.
"""
def __init__(self, event_type="", message=""):
"""
Init method for InstantiationError custom exception class.
Arguments:
event_type (str): name of the event raising the exception.
message (str): message describing why the exception was raised.
"""
super().__init__(
message="InstantiationError {event_type}: {message}".format(
event_type=event_type, message=message
)
)
class SenderValidationError(OpenEdxEventException):
"""
Describes errors that occur while validating arguments of send methods.
"""
def __init__(self, event_type="", message=""):
"""
Init method for SenderValidationError custom exception class.
Arguments:
event_type (str): name of the event raising the exception.
message (str): message describing why the exception was raised.
"""
super().__init__(
message="SenderValidationError {event_type}: {message}".format(
event_type=event_type, message=message
)
)