# HG changeset patch # User Goffi # Date 1547221105 -3600 # Node ID ef565839dadacdf0d1e3a5fe03f51562262da0d9 # Parent dfd6545a205a266cba05bd6cf452039444c7850a server: don't convert failure in errback to jsonrpclib.Fault anymore: failure in bridgeCall was always converted to jsonrpclib.Fault, resulting in loss of useful debugging data. This conversion as been modified to the signal handler which is only used by Libervia Legacy. Note that txJsonRPC will be totally removed for 0.8 release. diff -r dfd6545a205a -r ef565839dada libervia/server/server.py --- a/libervia/server/server.py Sun Jan 06 17:45:44 2019 +0100 +++ b/libervia/server/server.py Fri Jan 11 16:38:25 2019 +0100 @@ -527,8 +527,16 @@ jsonrpc.JSONRPC.__init__(self) self.sat_host = sat_host + def _bridgeCallEb(self, failure_): + """Raise a jsonrpclib failure for the frontend""" + return failure.Failure( + jsonrpclib.Fault(C.ERRNUM_BRIDGE_ERRBACK, failure_.value.classname) + ) + def asyncBridgeCall(self, method_name, *args, **kwargs): - return self.sat_host.bridgeCall(method_name, *args, **kwargs) + d = self.sat_host.bridgeCall(method_name, *args, **kwargs) + d.addErrback(self._bridgeCallEb) + return d class MethodHandler(JSONRPCMethodManager): @@ -1574,13 +1582,18 @@ parsed = jsonrpclib.loads(request.content.read()) profile = session_iface.ISATSession(_session).profile if not profile: + # FIXME: this method should not use _cbRender + # but all txJsonRPC code will be removed in 0.8 in favor of webRTC + # and it is currently used only with Libervia legacy app, + # so we do a is_jsonp workaround for now + self.is_jsonp = False # user is not identified, we return a jsonrpc fault fault = jsonrpclib.Fault( C.ERRNUM_LIBERVIA, C.NOT_ALLOWED ) # FIXME: define some standard error codes for libervia return jsonrpc.JSONRPC._cbRender( self, fault, request, parsed.get("id"), parsed.get("jsonrpc") - ) # pylint: disable=E1103 + ) self.request = request return jsonrpc.JSONRPC.render(self, request) @@ -2026,12 +2039,8 @@ Exception("Multiple return arguments not supported") d.callback(args[0]) - def _errback(result): - d.errback( - failure.Failure( - jsonrpclib.Fault(C.ERRNUM_BRIDGE_ERRBACK, result.classname) - ) - ) + def _errback(failure_): + d.errback(failure.Failure(failure_)) kwargs["callback"] = _callback kwargs["errback"] = _errback @@ -2198,7 +2207,7 @@ try: connected = yield self.bridgeCall(connect_method, profile, password) except Exception as failure_: - fault = failure_.faultString + fault = failure_.classname self.waiting_profiles.purgeRequest(profile) if fault in ("PasswordError", "ProfileUnknownError"): log.info(u"Profile {profile} doesn't exist or the submitted password is " @@ -2213,7 +2222,7 @@ u"connection is broken)")) raise exceptions.TimeOutError else: - log.error(u'Unmanaged fault string "{fault}" in errback for the ' + log.error(u'Unmanaged fault class "{fault}" in errback for the ' u'connection of profile {profile}'.format( fault=fault, profile=profile)) raise failure.Failure(exceptions.InternalError(fault))