improve error message parsing by checking regex result
This commit is contained in:
parent
4f64969638
commit
0ac3b3f2da
1 changed files with 8 additions and 5 deletions
|
|
@ -27,11 +27,14 @@ class MPDException(Exception):
|
||||||
|
|
||||||
|
|
||||||
def _parse_error(self, error):
|
def _parse_error(self, error):
|
||||||
|
if error:
|
||||||
parts = re.match("\[(\d+)@(\d+)\]\s\{(\w+)\}\s(.*)", error)
|
parts = re.match("\[(\d+)@(\d+)\]\s\{(\w+)\}\s(.*)", error)
|
||||||
|
if parts:
|
||||||
self._error = int(parts.group(1))
|
self._error = int(parts.group(1))
|
||||||
self._command_number = int(parts.group(2))
|
self._command_number = int(parts.group(2))
|
||||||
self._command_name = parts.group(3)
|
self._command_name = parts.group(3)
|
||||||
return parts.group(4)
|
return parts.group(4)
|
||||||
|
return error
|
||||||
|
|
||||||
|
|
||||||
def get_error(self):
|
def get_error(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue