diff options
author | Tristan Maat <tristan.maat@codethink.co.uk> | 2019-11-18 16:50:57 +0000 |
---|---|---|
committer | Tristan Maat <tristan.maat@codethink.co.uk> | 2019-11-22 11:41:31 +0000 |
commit | 176338b5cc20ac64b2b85bf83f704af7b26f3e6a (patch) | |
tree | 6fba22e388893623fb57841e55cfb6561badb292 /src | |
parent | 358727cdd2d3e3e2fccf6731c4a42910e7672202 (diff) | |
download | buildstream-176338b5cc20ac64b2b85bf83f704af7b26f3e6a.tar.gz |
Fix stacktraces during element loading
These were caused by unhandled errors from plugins when calling
`Source.get_consistency()`. This doesn't really solve the problem,
since that interface is still used un-wrapped elsewhere, but it
enables removing `Element.__schedule_tracking()` and fixes a bug.
Ultimately we'd like to remove `Source.get_consistency()`, so this
isn't too long-term of a problem.
Diffstat (limited to 'src')
-rw-r--r-- | src/buildstream/source.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/buildstream/source.py b/src/buildstream/source.py index 2e7460439..dbe113409 100644 --- a/src/buildstream/source.py +++ b/src/buildstream/source.py @@ -170,7 +170,7 @@ from . import _yaml, utils from .node import MappingNode from .plugin import Plugin from .types import Consistency, SourceRef, Union, List -from ._exceptions import BstError, ImplError, ErrorDomain +from ._exceptions import BstError, ImplError, PluginError, ErrorDomain from ._loader.metasource import MetaSource from ._projectrefs import ProjectRefStorage from ._cachekey import generate_key @@ -763,7 +763,20 @@ class Source(Plugin): # Source consistency interrogations are silent. context = self._get_context() with context.messenger.silence(): - self.__consistency = self.get_consistency() # pylint: disable=assignment-from-no-return + try: + self.__consistency = self.get_consistency() # pylint: disable=assignment-from-no-return + except SourceError: + # SourceErrors should be preserved so that the + # plugin can communicate real error cases. + raise + except Exception as err: # pylint: disable=broad-except + # Generic errors point to bugs in the plugin, so + # we need to catch them and make sure they do not + # cause stacktraces + raise PluginError( + "Source plugin '{}' failed to compute source consistency: {}".format(self.get_kind(), err), + reason="source-bug", + ) # Give the Source an opportunity to validate the cached # sources as soon as the Source becomes Consistency.CACHED. |