From 12bec16037f348ae36cfb95a4a31f1c0dd4c325f Mon Sep 17 00:00:00 2001 From: Andrii Zymohliad Date: Sat, 29 Jul 2023 19:49:50 +0300 Subject: [PATCH] Fix error reporting for unknown MPRIS properties --- cozy/control/mpris.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cozy/control/mpris.py b/cozy/control/mpris.py index be147d3e..00bd2d88 100644 --- a/cozy/control/mpris.py +++ b/cozy/control/mpris.py @@ -31,6 +31,10 @@ log = logging.getLogger("offline_cache") +class UnsupportedProperty(Exception): + pass + + class Server: def __init__(self, con, path): method_outargs = {} @@ -84,13 +88,15 @@ def on_method_call(self, invocation.return_value(variant) else: invocation.return_value(None) + except UnsupportedProperty: + invocation.return_dbus_error("{}.Error.NotSupported".format(interface_name), "Unsupported property") except Exception as e: log.error(e) reporter.exception("mpris", e) reporter.error("mpris", "MPRIS method call failed with method name: {}".format(method_name)) if out_args: reporter.error("mpris", "MPRIS method call failed with out_args: {}".format(out_args)) - invocation.return_value(None) + invocation.return_dbus_error("{}.Error.Failed".format(interface_name), "Internal exception occurred") class MPRIS(Server): @@ -270,7 +276,7 @@ def Get(self, interface, property_name): return GLib.Variant("d", self._player.volume) else: reporter.warning("mpris", "MPRIS required an unknown information: {}".format(property_name)) - return None + raise UnsupportedProperty def GetAll(self, interface): ret = {}