protocol: print the DeviceError as something useful

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
pull/191/head
Peter Hutterer 2019-08-22 11:51:21 +10:00 committed by Benjamin Tissoires
parent 88d9cf14bd
commit 7a121cfe6c
2 changed files with 10 additions and 1 deletions

View File

@ -446,6 +446,12 @@ class DeviceError(ProtocolError):
if self.errorcode == DeviceError.ErrorCode.INVALID_STATE:
self.errno = errno.EBADE
def __repr__(self):
return f'DeviceError.{self.errorcode.name}'
def __str__(self):
return repr(self)
class Msg(object):
'''

View File

@ -23,7 +23,7 @@ from gi.repository import GObject
from .drawing import Drawing
from .uhid import UHIDDevice
import tuhi.protocol
from tuhi.protocol import NordicData, Interactions, Mode, ProtocolVersion, StrokeFile, UnexpectedDataError, DeviceError, MissingReplyError
from tuhi.protocol import NordicData, Interactions, Mode, ProtocolVersion, StrokeFile, UnexpectedDataError, DeviceError, MissingReplyError, AuthorizationError
from .util import list2hex, flatten
from tuhi.config import TuhiConfig
@ -1017,6 +1017,9 @@ class WacomDevice(GObject.Object):
except DeviceError as e:
logger.error(f'**** Exception: {e} ****')
exception = e
except AuthorizationError as e:
logger.error(f'Authorization failed, device needs to be re-registered')
exception = e
finally:
self.sync_state = 0
self._is_running = False