# Buggy code
def execute(self, cmdstr: str):
    """
    Execute a command string. May raise CommandError.
    """
    parts = list(lexer(cmdstr))
    if not len(parts) >= 1:
        raise exceptions.CommandError("Invalid command: %s" % cmdstr)
    return self.call_strings(parts[0], parts[1:])


# Traceback (ValueError)
Traceback (most recent call last):
File "/home/kajoj/Mitmproxy/mitmproxy/mitmproxy/tools/console/master.py", line 216, in run
self.loop.run()
File "/home/kajoj/Mitmproxy/mitmproxy/venv/lib/python3.5/site-packages/urwid/main_loop.py", line 278, in run
self._run()
File "/home/kajoj/Mitmproxy/mitmproxy/venv/lib/python3.5/site-packages/urwid/main_loop.py", line 376, in _run
self.event_loop.run()
File "/home/kajoj/Mitmproxy/mitmproxy/venv/lib/python3.5/site-packages/urwid/main_loop.py", line 682, in run
self._loop()
File "/home/kajoj/Mitmproxy/mitmproxy/venv/lib/python3.5/site-packages/urwid/main_loop.py", line 719, in _loop
self._watch_files[fd]()
File "/home/kajoj/Mitmproxy/mitmproxy/venv/lib/python3.5/site-packages/urwid/raw_display.py", line 393, in <lambda>
event_loop, callback, self.get_available_raw_input())
File "/home/kajoj/Mitmproxy/mitmproxy/venv/lib/python3.5/site-packages/urwid/raw_display.py", line 493, in parse_input
callback(processed, processed_codes)
File "/home/kajoj/Mitmproxy/mitmproxy/venv/lib/python3.5/site-packages/urwid/main_loop.py", line 403, in _update
self.process_input(keys)
File "/home/kajoj/Mitmproxy/mitmproxy/venv/lib/python3.5/site-packages/urwid/main_loop.py", line 503, in process_input
k = self._topmost_widget.keypress(self.screen_size, k)
File "/home/kajoj/Mitmproxy/mitmproxy/mitmproxy/tools/console/window.py", line 308, in keypress
k = super().keypress(size, k)
File "/home/kajoj/Mitmproxy/mitmproxy/venv/lib/python3.5/site-packages/urwid/container.py", line 1116, in keypress
return self.footer.keypress((maxcol,),key)
File "/home/kajoj/Mitmproxy/mitmproxy/mitmproxy/tools/console/statusbar.py", line 149, in keypress
return self.ab.keypress(*args, **kwargs)
File "/home/kajoj/Mitmproxy/mitmproxy/mitmproxy/tools/console/statusbar.py", line 104, in keypress
self.prompt_execute(self._w.get_edit_text())
File "/home/kajoj/Mitmproxy/mitmproxy/mitmproxy/tools/console/statusbar.py", line 124, in prompt_execute
msg = p(txt)
File "/home/kajoj/Mitmproxy/mitmproxy/mitmproxy/tools/console/commandexecutor.py", line 17, in __call__
ret = self.master.commands.call(cmd)
File "/home/kajoj/Mitmproxy/mitmproxy/mitmproxy/command.py", line 218, in call
parts = list(lexer(cmdstr))
File "/usr/lib/python3.5/shlex.py", line 263, in __next__
token = self.get_token()
File "/usr/lib/python3.5/shlex.py", line 90, in get_token
raw = self.read_token()
File "/usr/lib/python3.5/shlex.py", line 185, in read_token
raise ValueError("No escaped character")
ValueError: No escaped character

# Fixed code
def execute(self, cmdstr: str):
    """
    Execute a command string. May raise CommandError.
    """
    try:
        parts = list(lexer(cmdstr))
    except ValueError as e:
        raise exceptions.CommandError("Command error: %s" % e)
    if not len(parts) >= 1:
        raise exceptions.CommandError("Invalid command: %s" % cmdstr)
    return self.call_strings(parts[0], parts[1:])