summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-01-11 21:58:56 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-01-11 22:40:25 +0900
commit9e23c2856095bb919cc60f31bfbc28b404a8e9d3 (patch)
tree9177a776d1a498b5b68b565dac3c96eac2e2acb3
parentc7ed4376481f0d6795de8bf5d3fc66ff495eb82d (diff)
downloadbuildstream-9e23c2856095bb919cc60f31bfbc28b404a8e9d3.tar.gz
_exceptions.py: Added `detail` member to base BstError class.
Now any BuildStream exception can potentially add detail to the errors they raise. Allow detail strings already in PluginError()
-rw-r--r--buildstream/_exceptions.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/buildstream/_exceptions.py b/buildstream/_exceptions.py
index 8dd57b617..da6a81365 100644
--- a/buildstream/_exceptions.py
+++ b/buildstream/_exceptions.py
@@ -79,11 +79,16 @@ class ErrorDomain(Enum):
#
class BstError(Exception):
- def __init__(self, message, *, domain=None, reason=None):
+ def __init__(self, message, *, detail=None, domain=None, reason=None):
global _last_exception
super().__init__(message)
+ # Additional error detail, these are used to construct detail
+ # portions of the logging messages when encountered.
+ #
+ self.detail = detail
+
# The build sandbox in which the error occurred, if the
# error occurred at element assembly time.
#
@@ -210,7 +215,7 @@ class ArtifactError(BstError):
#
class PipelineError(BstError):
- def __init__(self, message=None, reason=None):
+ def __init__(self, message=None, *, detail=None, reason=None):
# The empty string should never appear to a user,
# this only allows us to treat this internal error as
@@ -218,4 +223,4 @@ class PipelineError(BstError):
if message is None:
message = ""
- super().__init__(message, domain=ErrorDomain.PIPELINE, reason=reason)
+ super().__init__(message, detail=detail, domain=ErrorDomain.PIPELINE, reason=reason)