diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-10-04 21:02:45 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-10-10 19:29:59 +0900 |
commit | 41794f825f2ebb2055d6eded4821403352d5c9fd (patch) | |
tree | 6ec91ad3de227c43fd6e975a22cb4da080221365 | |
parent | fa512fef4765cc63ceeb4a901a3a517cb83606d6 (diff) | |
download | buildstream-41794f825f2ebb2055d6eded4821403352d5c9fd.tar.gz |
exceptions.py: Added _get_last_exception() for testing
So when we run the full CLI, we can test failure modes by
inspecting the last raised exception.
-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. |