mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
fix re-raised exceptions not having a message
This commit is contained in:
parent
04c88b49c8
commit
78dc2094b0
@ -284,7 +284,7 @@ def parsearg(manager: CommandManager, spec: str, argtype: type) -> typing.Any:
|
|||||||
try:
|
try:
|
||||||
return t.parse(manager, argtype, spec)
|
return t.parse(manager, argtype, spec)
|
||||||
except exceptions.TypeError as e:
|
except exceptions.TypeError as e:
|
||||||
raise exceptions.CommandError from e
|
raise exceptions.CommandError(str(e)) from e
|
||||||
|
|
||||||
|
|
||||||
def command(name: typing.Optional[str] = None):
|
def command(name: typing.Optional[str] = None):
|
||||||
|
@ -134,7 +134,7 @@ class _IntType(_BaseType):
|
|||||||
try:
|
try:
|
||||||
return int(s)
|
return int(s)
|
||||||
except ValueError as e:
|
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:
|
def is_valid(self, manager: "CommandManager", typ: typing.Any, val: typing.Any) -> bool:
|
||||||
return isinstance(val, int)
|
return isinstance(val, int)
|
||||||
@ -328,7 +328,7 @@ class _FlowType(_BaseFlowType):
|
|||||||
try:
|
try:
|
||||||
flows = manager.execute("view.flows.resolve %s" % (s))
|
flows = manager.execute("view.flows.resolve %s" % (s))
|
||||||
except exceptions.CommandError as e:
|
except exceptions.CommandError as e:
|
||||||
raise exceptions.TypeError from e
|
raise exceptions.TypeError(str(e)) from e
|
||||||
if len(flows) != 1:
|
if len(flows) != 1:
|
||||||
raise exceptions.TypeError(
|
raise exceptions.TypeError(
|
||||||
"Command requires one flow, specification matched %s." % len(flows)
|
"Command requires one flow, specification matched %s." % len(flows)
|
||||||
@ -347,7 +347,7 @@ class _FlowsType(_BaseFlowType):
|
|||||||
try:
|
try:
|
||||||
return manager.execute("view.flows.resolve %s" % (s))
|
return manager.execute("view.flows.resolve %s" % (s))
|
||||||
except exceptions.CommandError as e:
|
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:
|
def is_valid(self, manager: "CommandManager", typ: typing.Any, val: typing.Any) -> bool:
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user