Skip to content

Commit

Permalink
Fix error reporting for unknown MPRIS properties
Browse files Browse the repository at this point in the history
  • Loading branch information
azymohliad authored and geigi committed Dec 3, 2023
1 parent 2a797fc commit 12bec16
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cozy/control/mpris.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
log = logging.getLogger("offline_cache")


class UnsupportedProperty(Exception):
pass


class Server:
def __init__(self, con, path):
method_outargs = {}
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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 = {}
Expand Down

0 comments on commit 12bec16

Please sign in to comment.