diff options
-rw-r--r-- | buildstream/_exceptions.py | 34 | ||||
-rw-r--r-- | buildstream/_frontend/main.py | 28 | ||||
-rw-r--r-- | buildstream/_ostree.py | 4 | ||||
-rw-r--r-- | buildstream/_pipeline.py | 16 | ||||
-rw-r--r-- | buildstream/_scheduler/job.py | 6 | ||||
-rw-r--r-- | buildstream/element.py | 6 | ||||
-rw-r--r-- | buildstream/plugin.py | 4 | ||||
-rw-r--r-- | buildstream/source.py | 4 |
8 files changed, 52 insertions, 50 deletions
diff --git a/buildstream/_exceptions.py b/buildstream/_exceptions.py index 587e8dd80..328dcca4e 100644 --- a/buildstream/_exceptions.py +++ b/buildstream/_exceptions.py @@ -40,12 +40,12 @@ def _get_last_exception(): # context to exceptions raised by plugins in child tasks, this # context can then be communicated back to the main process. # -class _BstError(Exception): +class BstError(Exception): def __init__(self, message): global _last_exception - super(_BstError, self).__init__(message) + super(BstError, self).__init__(message) # The build sandbox in which the error occurred, if the # error occurred at element assembly time. @@ -63,7 +63,7 @@ class _BstError(Exception): # This exception is raised either by the plugin loading process, # or by the base :class:`.Plugin` element itself. # -class PluginError(_BstError): +class PluginError(BstError): pass @@ -116,7 +116,7 @@ class LoadErrorReason(Enum): # This exception is raised when loading or parsing YAML, or when # interpreting project YAML # -class LoadError(_BstError): +class LoadError(BstError): def __init__(self, reason, message): super(LoadError, self).__init__(message) @@ -130,7 +130,7 @@ class LoadError(_BstError): # Raised when a :class:`.Source` or :class:`.Element` plugin fails to # implement a mandatory method # -class ImplError(_BstError): +class ImplError(BstError): pass @@ -143,14 +143,14 @@ class ImplError(_BstError): # can not be found. E.g. The :class:`.Sandbox` class expects that # bubblewrap is installed for it to work. # -class ProgramNotFoundError(_BstError): +class ProgramNotFoundError(BstError): pass # PlatformError # # Raised if the current platform is not supported. -class PlatformError(_BstError): +class PlatformError(BstError): pass @@ -158,7 +158,7 @@ class PlatformError(_BstError): # # Raised when errors are encountered by the sandbox implementation # -class SandboxError(_BstError): +class SandboxError(BstError): pass @@ -166,5 +166,21 @@ class SandboxError(_BstError): # # Raised when errors are encountered in the artifact caches # -class ArtifactError(_BstError): +class ArtifactError(BstError): pass + + +# PipelineError +# +# Raised when a pipeline fails +# +class PipelineError(BstError): + + def __init__(self, message=None): + + # The empty string should never appear to a user, + # this only allows us to treat this internal error as + # a BstError from the frontend. + if message is None: + message = "" + super(PipelineError, self).__init__(message) diff --git a/buildstream/_frontend/main.py b/buildstream/_frontend/main.py index 662f267cb..33e900d5c 100644 --- a/buildstream/_frontend/main.py +++ b/buildstream/_frontend/main.py @@ -28,7 +28,7 @@ from blessings import Terminal from .. import Context, Project, Scope, Consistency # Import various buildstream internals -from .._exceptions import _BstError, LoadError +from .._exceptions import BstError, LoadError from .._message import MessageType, unconditional_messages from .._pipeline import Pipeline, PipelineError from .._scheduler import Scheduler @@ -313,7 +313,7 @@ def pull(app, elements, deps): to_pull = app.pipeline.deps_elements(deps) app.pipeline.pull(app.scheduler, to_pull) click.echo("") - except _BstError as e: + except BstError as e: click.echo("") click.echo("ERROR: {}".format(e)) sys.exit(-1) @@ -343,7 +343,7 @@ def push(app, elements, deps): to_push = app.pipeline.deps_elements(deps) app.pipeline.push(app.scheduler, to_push) click.echo("") - except _BstError as e: + except BstError as e: click.echo("") click.echo("ERROR: {}".format(e)) sys.exit(-1) @@ -489,7 +489,7 @@ def shell(app, element, sysroot, build, command): try: exitcode = app.pipeline.targets[0]._shell(scope, sysroot, command=command) sys.exit(exitcode) - except _BstError as e: + except BstError as e: click.echo("") click.echo("Errors shelling into this pipeline: %s" % str(e)) sys.exit(-1) @@ -514,7 +514,7 @@ def checkout(app, element, directory, force, integrate): try: app.pipeline.checkout(directory, force, integrate) click.echo("") - except _BstError as e: + except BstError as e: click.echo("") click.echo("ERROR: {}".format(e)) sys.exit(-1) @@ -548,7 +548,7 @@ def source_bundle(app, target, force, directory, app.pipeline.source_bundle(app.scheduler, dependencies, force, track, compression, directory) click.echo("") - except _BstError as e: + except BstError as e: click.echo("") click.echo("ERROR: {}".format(e)) sys.exit(-1) @@ -586,7 +586,7 @@ def workspace_open(app, no_checkout, force, source, track, element, directory): try: app.pipeline.open_workspace(app.scheduler, directory, source, no_checkout, track, force) click.echo("") - except _BstError as e: + except BstError as e: click.echo("") click.echo("ERROR: {}".format(e)) sys.exit(-1) @@ -615,7 +615,7 @@ def workspace_close(app, source, remove_dir, element): try: app.pipeline.close_workspace(source, remove_dir) click.echo("") - except _BstError as e: + except BstError as e: click.echo("") click.echo("ERROR: {}".format(e)) sys.exit(-1) @@ -645,7 +645,7 @@ def workspace_reset(app, source, track, no_checkout, element): try: app.pipeline.reset_workspace(app.scheduler, source, track, no_checkout) click.echo("") - except _BstError as e: + except BstError as e: click.echo("") click.echo("ERROR: {}".format(e)) sys.exit(-1) @@ -665,13 +665,13 @@ def workspace_list(app): try: context = Context(app.main_options['option']) context.load(config) - except _BstError as e: + except BstError as e: click.echo("Error loading user configuration: {}".format(e)) sys.exit(-1) try: project = Project(directory, context) - except _BstError as e: + except BstError as e: click.echo("Error loading project: {}".format(e)) sys.exit(-1) @@ -765,7 +765,7 @@ class App(): try: self.context = Context(self.main_options['option']) self.context.load(config) - except _BstError as e: + except BstError as e: click.echo("Error loading user configuration: %s" % str(e)) sys.exit(-1) @@ -823,7 +823,7 @@ class App(): try: self.project = Project(directory, self.context) - except _BstError as e: + except BstError as e: click.echo("Error loading project: %s" % str(e)) sys.exit(-1) @@ -836,7 +836,7 @@ class App(): resolve_ticker=self.resolve_ticker, remote_ticker=self.remote_ticker, cache_ticker=self.cache_ticker) - except _BstError as e: + except BstError as e: click.echo("Error loading pipeline: %s" % str(e)) sys.exit(-1) diff --git a/buildstream/_ostree.py b/buildstream/_ostree.py index 8e390e94b..794c57df3 100644 --- a/buildstream/_ostree.py +++ b/buildstream/_ostree.py @@ -26,7 +26,7 @@ import os import subprocess from . import _site from . import utils -from ._exceptions import _BstError +from ._exceptions import BstError import gi gi.require_version('OSTree', '1.0') @@ -35,7 +35,7 @@ from gi.repository.GLib import Variant, VariantDict # nopep8 # For users of this file, they must expect (except) it. -class OSTreeError(_BstError): +class OSTreeError(BstError): pass diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py index c7cd61ecf..90ed899ea 100644 --- a/buildstream/_pipeline.py +++ b/buildstream/_pipeline.py @@ -29,7 +29,7 @@ from operator import itemgetter from tempfile import TemporaryDirectory from pluginbase import PluginBase -from ._exceptions import _BstError, ArtifactError, ImplError, LoadError +from ._exceptions import PipelineError, ArtifactError, ImplError from ._message import Message, MessageType from ._elementfactory import ElementFactory from ._loader import Loader @@ -44,20 +44,6 @@ from .element import Element from ._scheduler import SchedStatus, TrackQueue, FetchQueue, BuildQueue, PullQueue, PushQueue -# Internal exception raised when a pipeline fails -# -class PipelineError(_BstError): - - def __init__(self, message=None): - - # The empty string should never appear to a user, - # this only allows us to treat this internal error as - # a _BstError from the frontend. - if message is None: - message = "" - super(PipelineError, self).__init__(message) - - class Planner(): def __init__(self): self.depth_map = {} diff --git a/buildstream/_scheduler/job.py b/buildstream/_scheduler/job.py index d8e720d9f..43b6b7c78 100644 --- a/buildstream/_scheduler/job.py +++ b/buildstream/_scheduler/job.py @@ -30,7 +30,7 @@ import multiprocessing from ruamel import yaml # BuildStream toplevel imports -from .._exceptions import _BstError +from .._exceptions import BstError from .._message import Message, MessageType, unconditional_messages from ..plugin import _plugin_lookup from .. import _yaml, _signals, utils @@ -267,7 +267,7 @@ class Job(): envelope = Envelope('result', result) self.queue.put(envelope) - except _BstError as e: + except BstError as e: elapsed = datetime.datetime.now() - starttime if self.tries <= self.max_retries: @@ -281,7 +281,7 @@ class Job(): self.child_shutdown(1) except Exception as e: - # If an unhandled (not normalized to _BstError) occurs, that's a bug, + # If an unhandled (not normalized to BstError) occurs, that's a bug, # send the traceback and formatted exception back to the frontend # and print it to the log file. # diff --git a/buildstream/element.py b/buildstream/element.py index ac5d69ac6..6c55026ee 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -37,7 +37,7 @@ import shutil from . import _yaml from ._variables import Variables -from ._exceptions import _BstError, LoadError, LoadErrorReason, ImplError +from ._exceptions import BstError, LoadError, LoadErrorReason, ImplError from . import Plugin, Consistency from .project import BST_ARTIFACT_VERSION as BST_CORE_ARTIFACT_VERSION from . import SandboxFlags @@ -81,7 +81,7 @@ class Scope(Enum): """ -class ElementError(_BstError): +class ElementError(BstError): """Raised by Element implementations. This exception is raised when an :class:`.Element` encounters an error. @@ -1066,7 +1066,7 @@ class Element(Plugin): self.stage(sandbox) # Step 3 - Assemble collect = self.assemble(sandbox) - except _BstError as e: + except BstError as e: # If an error occurred assembling an element in a sandbox, # then tack on the sandbox directory to the error e.sandbox = rootdir diff --git a/buildstream/plugin.py b/buildstream/plugin.py index 23d34ab10..abbed7dca 100644 --- a/buildstream/plugin.py +++ b/buildstream/plugin.py @@ -77,7 +77,7 @@ from weakref import WeakValueDictionary from . import _yaml, _signals from . import utils -from ._exceptions import PluginError, ImplError, _BstError +from ._exceptions import PluginError, ImplError, BstError from ._message import Message, MessageType @@ -475,7 +475,7 @@ class Plugin(): self.__context._push_message_depth(silent_nested) yield - except _BstError as e: + except BstError as e: # Note the failure in status messages and reraise, the scheduler # expects an error when there is an error. elapsed = datetime.datetime.now() - starttime diff --git a/buildstream/source.py b/buildstream/source.py index aeae41220..629d41a6b 100644 --- a/buildstream/source.py +++ b/buildstream/source.py @@ -28,7 +28,7 @@ import shutil from contextlib import contextmanager from . import _yaml, _signals, utils -from ._exceptions import _BstError, ImplError, LoadError, LoadErrorReason +from ._exceptions import BstError, ImplError, LoadError, LoadErrorReason from . import Plugin @@ -55,7 +55,7 @@ class Consistency(): """ -class SourceError(_BstError): +class SourceError(BstError): """Raised by Source implementations. This exception is raised when a :class:`.Source` encounters an error. |