From b8fc18e7e98d6f9ce5778a0ca0a1cf0067274ce5 Mon Sep 17 00:00:00 2001 From: blagoev Date: Mon, 2 Oct 2017 11:15:28 +0300 Subject: [PATCH] Fix RPC server to include exception message --- lib/browser/rpc.js | 4 ++++ src/rpc.cpp | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/browser/rpc.js b/lib/browser/rpc.js index c11630b9..e9e9412c 100644 --- a/lib/browser/rpc.js +++ b/lib/browser/rpc.js @@ -248,6 +248,10 @@ function sendRequest(command, data, host = sessionHost) { } else if (error.type && error.type == 'dict') { let responseError = deserialize_json_value(error); + if (response.message && response.message !== '') { + responseError.message = response.message; + } + throw responseError; } diff --git a/src/rpc.cpp b/src/rpc.cpp index 4fb94670..5f6b9b2b 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -371,8 +371,7 @@ json RPCServer::perform_request(std::string name, const json &args) { catch (...) { exceptionAsJson = {{"error", "An exception occured while processing the request. Could not serialize the exception as JSON"}}; } - - return (json){{"error", exceptionAsJson}}; + return (json){{"error", exceptionAsJson}, {"message", ex.what()}}; } catch (std::exception &exception) { return (json){{"error", exception.what()}};