From 9e23c2856095bb919cc60f31bfbc28b404a8e9d3 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Thu, 11 Jan 2018 21:58:56 +0900 Subject: _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() --- buildstream/_exceptions.py | 11 ++++++++--- 1 file 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) -- cgit v1.2.1