From 123b03fb53eb5256eb7554cbcbbba2043533dd63 Mon Sep 17 00:00:00 2001 From: relisher Date: Fri, 29 Jun 2018 14:36:59 -0700 Subject: [PATCH] If error codes were creater than 300 and there was no error, error.code would be null breaking this package. Update this package in order to handle higher than 300 error codes and print information about the error. --- lib/client.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/client.js b/lib/client.js index 0e2b5b1..29d1a6c 100644 --- a/lib/client.js +++ b/lib/client.js @@ -37,7 +37,7 @@ var SparqlClient = module.exports = function (endpoint, options) { var responseHandler = function responseHandler(error, response, responseBody, callback) { var continuation = emptyFn; - if (error || response.statusCode >= 300) { + if (error) { var err; if (error && error.code == "ECONNREFUSED") { @@ -51,8 +51,14 @@ var SparqlClient = module.exports = function (endpoint, options) { new Error(err), null ], that); - } - else { + } else if (response.statusCode >= 300) { + var err; + err = response.statusCode + ": " + response.statusMessage; + continuation = nextTick(callback, [ + new Error(err), + null + ], that); + } else { try { responseBody = JSON.parse(responseBody); }