diff options
-rw-r--r-- | buildstream/exceptions.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/buildstream/exceptions.py b/buildstream/exceptions.py index 49aef8ec8..5e86c1e3f 100644 --- a/buildstream/exceptions.py +++ b/buildstream/exceptions.py @@ -25,6 +25,14 @@ Exceptions from enum import Enum +# The last raised exception, this is used in test cases only +_last_exception = None + + +def _get_last_exception(): + return _last_exception + + # BstError is an internal base exception class for BuildSream # exceptions. # @@ -35,6 +43,8 @@ from enum import Enum class _BstError(Exception): def __init__(self, message): + global _last_exception + super(_BstError, self).__init__(message) # The build sandbox in which the error occurred, if the @@ -42,6 +52,9 @@ class _BstError(Exception): # self.sandbox = None + # Hold on to the last raised exception for testing purposes + _last_exception = self + class PluginError(_BstError): """Raised on plugin related errors. |