diff --git a/lib/jsonrpc2.js b/lib/jsonrpc2.js index 89369db..e6cfc99 100644 --- a/lib/jsonrpc2.js +++ b/lib/jsonrpc2.js @@ -41,7 +41,8 @@ function JsonRpcObject() { } this.call = function(method, params, id) { - var data = HTTP.create("MSXML") + var result; + var response = HTTP.create("MSXML") .setContentType("application/json") .setDataType("json") .setRequestBody(encode(method, params, id)) @@ -50,7 +51,16 @@ function JsonRpcObject() { .responseBody ; - return data; + if ("error" in response) { + console.error(response.error.message); + return; + } + + if ("result" in response) { + result = response.result; + } + + return result; } }