From 78dc2094b0d92abcfac97427d88e56568ed9f487 Mon Sep 17 00:00:00 2001 From: Itai Sadan Date: Sat, 18 Jan 2020 12:59:59 +0200 Subject: [PATCH] fix re-raised exceptions not having a message --- mitmproxy/command.py | 2 +- mitmproxy/types.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mitmproxy/command.py b/mitmproxy/command.py index 8822bb9b8..bfec47e11 100644 --- a/mitmproxy/command.py +++ b/mitmproxy/command.py @@ -284,7 +284,7 @@ def parsearg(manager: CommandManager, spec: str, argtype: type) -> typing.Any: try: return t.parse(manager, argtype, spec) except exceptions.TypeError as e: - raise exceptions.CommandError from e + raise exceptions.CommandError(str(e)) from e def command(name: typing.Optional[str] = None): diff --git a/mitmproxy/types.py b/mitmproxy/types.py index ac9922172..0d4ffd696 100644 --- a/mitmproxy/types.py +++ b/mitmproxy/types.py @@ -134,7 +134,7 @@ class _IntType(_BaseType): try: return int(s) except ValueError as e: - raise exceptions.TypeError from e + raise exceptions.TypeError(str(e)) from e def is_valid(self, manager: "CommandManager", typ: typing.Any, val: typing.Any) -> bool: return isinstance(val, int) @@ -328,7 +328,7 @@ class _FlowType(_BaseFlowType): try: flows = manager.execute("view.flows.resolve %s" % (s)) except exceptions.CommandError as e: - raise exceptions.TypeError from e + raise exceptions.TypeError(str(e)) from e if len(flows) != 1: raise exceptions.TypeError( "Command requires one flow, specification matched %s." % len(flows) @@ -347,7 +347,7 @@ class _FlowsType(_BaseFlowType): try: return manager.execute("view.flows.resolve %s" % (s)) except exceptions.CommandError as e: - raise exceptions.TypeError from e + raise exceptions.TypeError(str(e)) from e def is_valid(self, manager: "CommandManager", typ: typing.Any, val: typing.Any) -> bool: try: