From 2a355692acdedc29f999e744ac87b054cfbd5917 Mon Sep 17 00:00:00 2001 From: Nathan Friedly Date: Wed, 27 Sep 2017 11:53:08 -0400 Subject: [PATCH] Provide raw solr response when JSON.parse fails While rare, network issues, proxies, and other problems can result in invalid or incomplete JSON. The error message in that case is may not be particularly helpful, so this provides the raw response in a new error.body field to aid in debugging. --- lib/solr.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/solr.js b/lib/solr.js index 73cbddc8..d828b9de 100644 --- a/lib/solr.js +++ b/lib/solr.js @@ -995,6 +995,7 @@ function handleJSONResponse(request, bigint, callback){ data = pickJSON(bigint).parse(text); }catch(error){ err = error; + err.body = text; }finally{ if(callback) callback(err,data); } @@ -1003,4 +1004,4 @@ function handleJSONResponse(request, bigint, callback){ }; }; -Promise.promisifyAll(Client.prototype); \ No newline at end of file +Promise.promisifyAll(Client.prototype);