diff options
Diffstat (limited to 'src/buildstream/_exceptions.py')
-rw-r--r-- | src/buildstream/_exceptions.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/buildstream/_exceptions.py b/src/buildstream/_exceptions.py index ca17577f7..85fcf61ee 100644 --- a/src/buildstream/_exceptions.py +++ b/src/buildstream/_exceptions.py @@ -20,6 +20,7 @@ from enum import Enum, unique import os +import sys # Disable pylint warnings for whole file here: # pylint: disable=global-statement @@ -239,10 +240,12 @@ class LoadErrorReason(Enum): # reason (LoadErrorReason): machine readable error reason # # This exception is raised when loading or parsing YAML, or when -# interpreting project YAML +# interpreting project YAML. Although reason has a default value, +# the arg must be assigned to a LoadErrorReason. This is a workaround +# for unpickling subclassed Exception() classes. # class LoadError(BstError): - def __init__(self, message, reason, *, detail=None): + def __init__(self, message, reason=None, *, detail=None): super().__init__(message, detail=detail, domain=ErrorDomain.LOAD, reason=reason) @@ -385,3 +388,19 @@ class ArtifactElementError(BstError): class ProfileError(BstError): def __init__(self, message, detail=None, reason=None): super().__init__(message, detail=detail, domain=ErrorDomain.PROFILE, reason=reason) + + +# SubprocessException +# +# Used with 'tblib.pickling_suport' to pickle the exception & traceback +# object thrown from subprocessing a Stream entry point, e.g. build(). +# The install() method of pickling_support must be called before attempting +# to pickle this object. +# +class SubprocessException: + def __init__(self, exception): + self.exception = exception + __, __, self.tb = sys.exc_info() + + def re_raise(self): + raise self.exception.with_traceback(self.tb) |