Browse Source

Cleanup exceptions a bit

There is no need to override the constructor in every exception.

Change-Id: I551f551611ea4e8902337901512f8498afe16210
Pranesh Pandurangan 4 years ago
parent
commit
80d0194d86
1 changed files with 9 additions and 10 deletions
  1. 9
    10
      entropy/exceptions.py

+ 9
- 10
entropy/exceptions.py View File

@@ -17,32 +17,31 @@
17 17
 
18 18
 class EntropyException(Exception):
19 19
     """Base class for exceptions emitted from entropy."""
20
-    def __init__(self, message):
20
+    def __init__(self, message, cause=None):
21 21
         super(EntropyException, self).__init__(message)
22
+        self._cause = cause
23
+
24
+    @property
25
+    def cause(self):
26
+        return self._cause
22 27
 
23 28
 
24 29
 class TimeoutException(EntropyException):
25 30
     """Exceptions because of timeouts, eg. when the job queue has been empty
26 31
     really long.
27 32
     """
28
-    def __init__(self, message):
29
-        super(TimeoutException, self).__init__(message)
30 33
 
31 34
 
32 35
 class EngineStoppedException(EntropyException):
33
-    """Exception raised when engine is shutdown."""
34
-    def __init__(self, message):
35
-        super(EngineStoppedException, self).__init__(message)
36
+    """Exception raised when operations are performed against an engine that
37
+    is shutdown.
38
+    """
36 39
 
37 40
 
38 41
 class NoSuchEngineException(EntropyException):
39 42
     """Exception raised when performing operations on a non-existent engine.
40 43
     """
41
-    def __init__(self, message):
42
-        super(NoSuchEngineException, self).__init__(message)
43 44
 
44 45
 
45 46
 class NoEnginesException(EntropyException):
46 47
     """Exception raised when there are no known engines."""
47
-    def __init__(self, message):
48
-        super(NoEnginesException, self).__init__(message)

Loading…
Cancel
Save