From 8f18e8a0fa96987de25d784f0df6c1066eee104e Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Sun, 10 Sep 2017 22:10:31 +0200 Subject: [bug] add the error as an upper level attribute of the dict the UI is expecting it there, not inside the result data. we probably could delete it from the later. --- src/leap/bitmask/core/dispatcher.py | 10 +++++++--- src/leap/bitmask/vpn/tunnel.py | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/leap/bitmask') diff --git a/src/leap/bitmask/core/dispatcher.py b/src/leap/bitmask/core/dispatcher.py index 363594ca..91168d87 100644 --- a/src/leap/bitmask/core/dispatcher.py +++ b/src/leap/bitmask/core/dispatcher.py @@ -186,8 +186,8 @@ class VPNCmd(SubCommand): @register_method('dict') def do_STATUS(self, vpn, *parts): - d = vpn.do_status() - return d + result = vpn.do_status() + return result @register_method('dict') def do_START(self, vpn, *parts): @@ -570,7 +570,11 @@ class CommandDispatcher(object): def _format_result(result): - return json.dumps({'error': None, 'result': result}) + if isinstance(result, dict) and result.get('error'): + error = result['error'] + else: + error = None + return json.dumps({'error': error, 'result': result}) def _format_error(failure): diff --git a/src/leap/bitmask/vpn/tunnel.py b/src/leap/bitmask/vpn/tunnel.py index 64796e9c..b49135df 100644 --- a/src/leap/bitmask/vpn/tunnel.py +++ b/src/leap/bitmask/vpn/tunnel.py @@ -118,8 +118,9 @@ class ConfiguredTunnel(object): running = yield self.__start_spawn_proc(vpnproc, cmd) vpnproc.pid = running.pid defer.returnValue(True) - except Exception: + except Exception as exc: self._vpnproc.failed = True + self._vpnproc.errmsg = exc.message raise def __start_pre_up(self, proc): -- cgit v1.2.3