diff --git a/beetsplug/bpd/__init__.py b/beetsplug/bpd/__init__.py index 0d16e22ca..4f04d01fc 100644 --- a/beetsplug/bpd/__init__.py +++ b/beetsplug/bpd/__init__.py @@ -674,7 +674,8 @@ class Command(object): # Attempt to get correct command function. func_name = 'cmd_' + self.name if not hasattr(conn.server, func_name): - raise BPDError(ERROR_UNKNOWN, u'unknown command', self.name) + raise BPDError(ERROR_UNKNOWN, + u'unknown command "{}"'.format(self.name)) func = getattr(conn.server, func_name) # Ensure we have permission for this command. @@ -690,6 +691,13 @@ class Command(object): for data in results: yield conn.send(data) + except TypeError: + # The client provided too many arguments. + raise BPDError(ERROR_ARG, + u'wrong number of arguments for "{}"' + .format(self.name), + self.name) + except BPDError as e: # An exposed error. Set the command name and then let # the Connection handle it. diff --git a/test/test_player.py b/test/test_player.py index d7f65ff3f..d2ea496c4 100644 --- a/test/test_player.py +++ b/test/test_player.py @@ -347,6 +347,11 @@ class BPDTest(BPDTestHelper): response = client.send_command('notacommand') self._assert_failed(response, bpd.ERROR_UNKNOWN) + def test_unexpected_argument(self): + with self.run_bpd() as client: + response = client.send_command('clearerror', 'extra argument') + self._assert_failed(response, bpd.ERROR_ARG) + class BPDQueryTest(BPDTestHelper): test_implements_query = implements({