diff --git a/src/stratis_cli/_error_reporting.py b/src/stratis_cli/_error_reporting.py index 1fdd06d7a..c0b25364f 100644 --- a/src/stratis_cli/_error_reporting.py +++ b/src/stratis_cli/_error_reporting.py @@ -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: @@ -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