From 68413d8676e71a4701137f17329035f1b940185d Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 9 Apr 2014 22:43:25 +0200 Subject: [PATCH] Better error for invalid argument count --- qutebrowser/commands/command.py | 4 +++- qutebrowser/commands/parsers.py | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/qutebrowser/commands/command.py b/qutebrowser/commands/command.py index b893d3462..1ec60ca09 100644 --- a/qutebrowser/commands/command.py +++ b/qutebrowser/commands/command.py @@ -81,7 +81,9 @@ class Command(QObject): pass else: raise ArgumentCountError("{}-{} args expected, but got {}".format( - self.nargs[0], self.nargs[1], len(args))) + self.nargs[0], + self.nargs[1] if self.nargs[1] is not None else 'inf', + len(args))) def run(self, args=None, count=None): """Run the command. diff --git a/qutebrowser/commands/parsers.py b/qutebrowser/commands/parsers.py index 82e502339..372753687 100644 --- a/qutebrowser/commands/parsers.py +++ b/qutebrowser/commands/parsers.py @@ -208,10 +208,10 @@ class CommandParser: try: self.parse(text) self._check() - except ArgumentCountError: + except ArgumentCountError as e: if ignore_exc: - message.error("{}: invalid argument count".format( - self._cmd.name)) + message.error("{}: invalid argument count - {}".format( + self._cmd.name, str(e))) return False else: raise