aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2016-07-14 10:19:16 +1200
committerAldo Cortesi <aldo@nullcube.com>2016-07-14 10:19:16 +1200
commitc52d567b4360ebbaa63918beb16a5f78649309a5 (patch)
tree65dc4fb60b12bdadc80b7e37f3d85d7425d13d86
parenta8a083a10d09509be8f39fb4463a857e0d3e2eeb (diff)
downloadmitmproxy-c52d567b4360ebbaa63918beb16a5f78649309a5.tar.gz
mitmproxy-c52d567b4360ebbaa63918beb16a5f78649309a5.tar.bz2
mitmproxy-c52d567b4360ebbaa63918beb16a5f78649309a5.zip
Handle OptionsError for command-line args.
-rw-r--r--mitmproxy/main.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/mitmproxy/main.py b/mitmproxy/main.py
index bf01a3cb..5ced709b 100644
--- a/mitmproxy/main.py
+++ b/mitmproxy/main.py
@@ -76,7 +76,11 @@ def mitmproxy(args=None): # pragma: no cover
server = get_server(console_options.no_server, proxy_config)
- m = console.master.ConsoleMaster(server, console_options)
+ try:
+ m = console.master.ConsoleMaster(server, console_options)
+ except exceptions.OptionsError as e:
+ print("mitmproxy: %s" % e, file=sys.stderr)
+ sys.exit(1)
try:
m.run()
except (KeyboardInterrupt, _thread.error):
@@ -109,7 +113,7 @@ def mitmdump(args=None): # pragma: no cover
signal.signal(signal.SIGTERM, cleankill)
master.run()
- except dump.DumpError as e:
+ except (dump.DumpError, exceptions.OptionsError) as e:
print("mitmdump: %s" % e, file=sys.stderr)
sys.exit(1)
except (KeyboardInterrupt, _thread.error):
@@ -137,7 +141,11 @@ def mitmweb(args=None): # pragma: no cover
server = get_server(web_options.no_server, proxy_config)
- m = web.master.WebMaster(server, web_options)
+ try:
+ m = web.master.WebMaster(server, web_options)
+ except exceptions.OptionsError as e:
+ print("mitmweb: %s" % e, file=sys.stderr)
+ sys.exit(1)
try:
m.run()
except (KeyboardInterrupt, _thread.error):