diff --git a/mitmproxy/dump.py b/mitmproxy/dump.py index b95d2627a..18c24d617 100644 --- a/mitmproxy/dump.py +++ b/mitmproxy/dump.py @@ -45,6 +45,7 @@ class DumpMaster(flow.FlowMaster): def __init__(self, server, options): flow.FlowMaster.__init__(self, options, server, flow.State()) + self.has_errored = False self.addons.add(*builtins.default_addons()) # This line is just for type hinting self.options = self.options # type: Options @@ -115,6 +116,8 @@ class DumpMaster(flow.FlowMaster): raise DumpError(str(e)) def add_log(self, e, level="info"): + if level == "error": + self.has_errored = True if self.options.verbosity >= utils.log_tier(level): self.echo( e, diff --git a/mitmproxy/main.py b/mitmproxy/main.py index 5ced709b9..316db91a8 100644 --- a/mitmproxy/main.py +++ b/mitmproxy/main.py @@ -118,6 +118,9 @@ def mitmdump(args=None): # pragma: no cover sys.exit(1) except (KeyboardInterrupt, _thread.error): pass + if master.has_errored: + print("mitmdump: errors occurred during run", file=sys.stderr) + sys.exit(1) def mitmweb(args=None): # pragma: no cover