mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
Make mitmdump return an error exit status if errors occurred during run
This commit is contained in:
parent
33d03d916a
commit
50f1495f29
@ -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,
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user