From 96e714a74cc861eef2fea3e4a8279793a6f42fe8 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 27 Jan 2011 15:20:07 +1300 Subject: [PATCH] Handle nonexistent load files gracefully. Also improve IOError statusbar messages. --- libmproxy/console.py | 7 +++---- mitmproxy | 5 ++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libmproxy/console.py b/libmproxy/console.py index 6c5a051e8..575cc092c 100644 --- a/libmproxy/console.py +++ b/libmproxy/console.py @@ -295,7 +295,7 @@ class ConnectionView(WWrap): f.write(str(c.content)) f.close() except IOError, v: - self.master.statusbar.message(str(v)) + self.master.statusbar.message(v.strerror) def edit(self, part): if self.viewing == self.REQ: @@ -772,7 +772,7 @@ class ConsoleMaster(controller.Master): f.write(data) f.close() except IOError, v: - self.statusbar.message(str(v)) + self.statusbar.message(v.strerror) def save_one_flow(self, path, flow): data = flow.dump() @@ -791,8 +791,7 @@ class ConsoleMaster(controller.Master): data = f.read() f.close() except IOError, v: - self.statusbar.message(str(v)) - return + return v.strerror self.state.load_flows(data, ConsoleFlow) if self.conn_list_view: self.conn_list_view.set_focus(0) diff --git a/mitmproxy b/mitmproxy index 2fc61a80d..4153ea44b 100755 --- a/mitmproxy +++ b/mitmproxy @@ -80,7 +80,10 @@ if __name__ == '__main__': m = console.ConsoleMaster(server, options) for i in args: - m.load_flows(i) + msg = m.load_flows(i) + if msg: + print >> sys.stderr, msg + sys.exit(1) m.run()