Skip to content

Commit

Permalink
Applet: Handle UnknownObject DBus error.
Browse files Browse the repository at this point in the history
  • Loading branch information
tommie authored and cschramm committed Oct 16, 2024
1 parent 52f0f03 commit b8a7cbd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions blueman/bluez/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ class DBusUnsupportedMajorClassError(BluezDBusException):
pass


class DBusUnknownObjectError(BluezDBusException):
pass


class DBusServiceUnknownError(BluezDBusException):
pass

Expand Down Expand Up @@ -121,6 +125,7 @@ class BluezUnavailableAgentMethodError(BluezDBusException):
'org.bluez.Error.AuthenticationCanceled': DBusAuthenticationCanceledError,
'org.bluez.serial.Error.NotSupported': DBusNotSupportedError,
'org.bluez.Error.UnsupportedMajorClass': DBusUnsupportedMajorClassError,
'org.freedesktop.DBus.Error.UnknownObject': DBusUnknownObjectError,
'org.freedesktop.DBus.Error.ServiceUnknown': DBusServiceUnknownError}


Expand Down
8 changes: 6 additions & 2 deletions blueman/plugins/applet/RecentConns.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from blueman.bluemantyping import ObjectPath, BtAddress

from blueman.bluez.Device import Device
from blueman.bluez.errors import DBusNoSuchAdapterError
from blueman.bluez.errors import DBusNoSuchAdapterError, DBusUnknownObjectError
from blueman.gui.Notification import Notification
from blueman.Sdp import ServiceUUID
from blueman.plugins.AppletPlugin import AppletPlugin
Expand Down Expand Up @@ -200,7 +200,11 @@ def _get_device_path(self, adapter_path: ObjectPath, address: BtAddress) -> Opti
except DBusNoSuchAdapterError:
return None

device = self.parent.Manager.find_device(address, adapter.get_object_path())
try:
device = self.parent.Manager.find_device(address, adapter.get_object_path())
except DBusUnknownObjectError:
return None

return device.get_object_path() if device is not None else None

def _get_items(self) -> List["Item"]:
Expand Down

0 comments on commit b8a7cbd

Please sign in to comment.