[pushbullet] Fixed on_error callback on the listener.

The `Listener` class from the `pushbullet.py` library is a mess, and it
has two internal functions to handle errors.
This commit is contained in:
Fabio Manganiello 2024-01-13 13:24:47 +01:00
parent 18bba7e3bf
commit f0dcb94862
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -17,6 +17,7 @@ class Listener(_Listener):
on_close: Optional[Callable[[], None]] = None, on_close: Optional[Callable[[], None]] = None,
**kwargs, **kwargs,
): ):
kwargs['on_error'] = self._err_callback()
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self._on_open_hndl = on_open self._on_open_hndl = on_open
self._on_close_hndl = on_close self._on_close_hndl = on_close
@ -42,5 +43,11 @@ class Listener(_Listener):
return callback return callback
def _err_callback(self):
def callback(e):
self.logger.error('Pushbullet listener error: %s: %s', type(e).__name__, e)
return callback
# vim:sw=4:ts=4:et: # vim:sw=4:ts=4:et: