From ace5a0220a015d4eca3782024701924112e0d981 Mon Sep 17 00:00:00 2001 From: Matthias Dellweg <2500@gmx.de> Date: Mon, 23 Mar 2020 13:08:50 +0100 Subject: [PATCH] Allow to use subclasses of DBusError Also mark the translated to dbus Exceptions as handled. --- dbus_next/message_bus.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dbus_next/message_bus.py b/dbus_next/message_bus.py index 0cfe5dd..533d97a 100644 --- a/dbus_next/message_bus.py +++ b/dbus_next/message_bus.py @@ -561,15 +561,17 @@ def __call__(self, reply): bus.send(reply) def __exit__(self, type, value, tb): - if type == DBusError: + if issubclass(type, DBusError): self(value._as_message(msg)) + return True - if type == Exception: + if issubclass(type, Exception): self( Message.new_error( msg, ErrorType.SERVICE_ERROR, f'The service interface raised an error: {value}.\n{traceback.format_tb(tb)}' )) + return True return SendReply()