summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2020-08-04 16:00:12 +0200
committerJürg Billeter <j@bitron.ch>2020-08-06 07:10:28 +0200
commit7a9dd098efa6d5070455f432e2557a321b2dfd76 (patch)
tree037b1ca00f4bc197202b975010af180f3f93c3ed
parent78aa20382a1e1ad87d3d552ca65f0c4da76a15c2 (diff)
downloadbuildstream-7a9dd098efa6d5070455f432e2557a321b2dfd76.tar.gz
_frontend/widget.py: Add context to errors in `show_pipeline()`
Provide context with the element name if an error is raised when trying to determine element state.
-rw-r--r--src/buildstream/_frontend/widget.py35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/buildstream/_frontend/widget.py b/src/buildstream/_frontend/widget.py
index f07e3dba0..5035afb98 100644
--- a/src/buildstream/_frontend/widget.py
+++ b/src/buildstream/_frontend/widget.py
@@ -29,7 +29,7 @@ import click
from .profile import Profile
from .. import Scope
from .. import __version__ as bst_version
-from .._exceptions import ImplError
+from .._exceptions import BstError, ImplError
from .._message import MessageType
from ..storage.directory import _FileType
@@ -346,21 +346,26 @@ class LogLine(Widget):
line = p.fmt_subst(line, "key", cache_key, fg="yellow", dim=dim_keys)
line = p.fmt_subst(line, "full-key", full_key, fg="yellow", dim=dim_keys)
- if not element._has_all_sources_resolved():
- line = p.fmt_subst(line, "state", "no reference", fg="red")
- else:
- if element.get_kind() == "junction":
- line = p.fmt_subst(line, "state", "junction", fg="magenta")
- elif element._cached_failure():
- line = p.fmt_subst(line, "state", "failed", fg="red")
- elif element._cached_success():
- line = p.fmt_subst(line, "state", "cached", fg="magenta")
- elif not element._has_all_sources_in_source_cache() and not element._has_all_sources_cached():
- line = p.fmt_subst(line, "state", "fetch needed", fg="red")
- elif element._buildable():
- line = p.fmt_subst(line, "state", "buildable", fg="green")
+ try:
+ if not element._has_all_sources_resolved():
+ line = p.fmt_subst(line, "state", "no reference", fg="red")
else:
- line = p.fmt_subst(line, "state", "waiting", fg="blue")
+ if element.get_kind() == "junction":
+ line = p.fmt_subst(line, "state", "junction", fg="magenta")
+ elif element._cached_failure():
+ line = p.fmt_subst(line, "state", "failed", fg="red")
+ elif element._cached_success():
+ line = p.fmt_subst(line, "state", "cached", fg="magenta")
+ elif not element._has_all_sources_in_source_cache() and not element._has_all_sources_cached():
+ line = p.fmt_subst(line, "state", "fetch needed", fg="red")
+ elif element._buildable():
+ line = p.fmt_subst(line, "state", "buildable", fg="green")
+ else:
+ line = p.fmt_subst(line, "state", "waiting", fg="blue")
+ except BstError as e:
+ # Provide context to plugin error
+ e.args = ("Failed to determine state for {}: {}".format(element._get_full_name(), str(e)),)
+ raise e
# Element configuration
if "%{config" in format_: