Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/stratis_cli/_error_reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,20 @@ def _interface_name_to_common_name(interface_name):
raise StratisCliUnknownInterfaceError(interface_name) # pragma: no cover


def get_errors(exc: Exception):
def get_errors(exc: BaseException):
"""
Generates a sequence of exceptions starting with exc and following the chain
of causes.
"""
while True:
yield exc
exc = getattr(exc, "__cause__") or getattr(exc, "__context__")
if exc is None:
return
yield exc
while exc.__cause__ is not None:
yield exc.__cause__
exc = exc.__cause__


def _interpret_errors_0(error):
def _interpret_errors_0(
error: dbus.exceptions.DBusException,
):
"""
Handle match on SCAE .* DBE
where:
Expand Down Expand Up @@ -121,7 +122,10 @@ def _interpret_errors_0(error):
# running with a new major version and is supplying a different name on the
# D-Bus than stratis is attempting to use. The second and third
# possibilities are both covered by a single error message.
if error.get_dbus_name() == "org.freedesktop.DBus.Error.NameHasNoOwner":
if error.get_dbus_name() in (
"org.freedesktop.DBus.Error.NameHasNoOwner",
"org.freedesktop.DBus.Error.ServiceUnknown",
):
try:
# pylint: disable=import-outside-toplevel
# isort: THIRDPARTY
Expand Down
Loading