diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-10-11 11:12:06 +1300 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-10-11 11:12:06 +1300 |
commit | 68f1000e429913593b7e963ab4a977aaa39a058d (patch) | |
tree | 41b07a32463a27e83b0f2787999b06902f3e4eca | |
parent | 0d59fd7e01ba74df901cae6f5f2d058235fa1c33 (diff) | |
download | mitmproxy-68f1000e429913593b7e963ab4a977aaa39a058d.tar.gz mitmproxy-68f1000e429913593b7e963ab4a977aaa39a058d.tar.bz2 mitmproxy-68f1000e429913593b7e963ab4a977aaa39a058d.zip |
Improve error reporting for one-shot scripts.
-rw-r--r-- | libmproxy/console/__init__.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/libmproxy/console/__init__.py b/libmproxy/console/__init__.py index 822c6e34..1153bdcd 100644 --- a/libmproxy/console/__init__.py +++ b/libmproxy/console/__init__.py @@ -431,20 +431,31 @@ class ConsoleMaster(flow.FlowMaster): return str(v) self.stream_path = path + + def _run_script_method(self, method, s, f): + status, val = s.run(method, f) + if val: + if status: + self.add_event("Method %s return: %s"%(method, val)) + else: + self.add_event("Method %s error: %s"%(method, val[1])) + def run_script_once(self, path, f): if not path: return + self.add_event("Running script on flow: %s"%path) ret = self.get_script(path) if ret[0]: - self.statusbar.message(ret[0]) + self.statusbar.message("Error loading script.") + self.add_event("Error loading script:\n%s"%ret[0]) return s = ret[1] if f.request: - s.run("request", f) + self._run_script_method("request", s, f) if f.response: - s.run("response", f) + self._run_script_method("response", s, f) if f.error: - s.run("error", f) + self._run_script_method("error", s, f) s.run("done") self.refresh_flow(f) self.state.last_script = path |