Fix error handling to operate on error number
Fix the handling of MPD errors to compare the error number instead of the complete, unparsed error message.
This commit is contained in:
parent
f843cc629d
commit
04effa0ec1
|
@ -19,6 +19,7 @@ from mcg.utils import Utils
|
|||
class MPDException(Exception):
|
||||
def __init__(self, error):
|
||||
super(MPDException, self).__init__(self._parse_error(error))
|
||||
self._error = error
|
||||
|
||||
|
||||
def _parse_error(self, error):
|
||||
|
@ -36,6 +37,10 @@ class MPDException(Exception):
|
|||
return self._error
|
||||
|
||||
|
||||
def get_error_number(self):
|
||||
return self._error_number
|
||||
|
||||
|
||||
def get_command_number(self):
|
||||
return self._command_number
|
||||
|
||||
|
@ -690,7 +695,7 @@ class Client(Base):
|
|||
break
|
||||
except CommandException as e:
|
||||
# If no albumart can be found, do not throw an exception
|
||||
if e.get_error() == Client.PROTOCOL_ERROR_NOEXISTS:
|
||||
if e.get_error_number() == Client.PROTOCOL_ERROR_NOEXISTS:
|
||||
data = None
|
||||
else:
|
||||
raise e
|
||||
|
@ -773,7 +778,7 @@ class Client(Base):
|
|||
self._write(command, args)
|
||||
return self._read()
|
||||
except MPDException as e:
|
||||
if command == 'idle' and e.get_error() == Client.PROTOCOL_ERROR_PERMISSION:
|
||||
if command == 'idle' and e.get_error_number() == Client.PROTOCOL_ERROR_PERMISSION:
|
||||
self.disconnect()
|
||||
self._callback(Client.SIGNAL_ERROR, e)
|
||||
|
||||
|
@ -782,7 +787,7 @@ class Client(Base):
|
|||
try:
|
||||
self._write(command, args)
|
||||
except MPDException as e:
|
||||
if command == 'idle' and e.get_error() == Client.PROTOCOL_ERROR_PERMISSION:
|
||||
if command == 'idle' and e.get_error_number() == Client.PROTOCOL_ERROR_PERMISSION:
|
||||
self.disconnect()
|
||||
self._callback(Client.SIGNAL_ERROR, e)
|
||||
|
||||
|
|
Loading…
Reference in a new issue