node-sparql-client icon indicating copy to clipboard operation
node-sparql-client copied to clipboard

responseHandler - no error but response.statusCode > 300

Open carlostighe opened this issue 9 years ago • 0 comments

I have come across an issue whereby my node is throwing this error:

if (error.code == "ECONNREFUSED") {
           ^
TypeError: Cannot read property 'code' of null

Doing some quick debugging shows that the error is null but that the response code is 400. This causes an the app to crash in client.js line 43. Looking at my own code I think I might have some misformed sparql queries but I thought I'd raise the issue anyway, for possible greater error handling.

    var responseHandler = function responseHandler(error, response, responseBody, callback) {
        var continuation = emptyFn;
        if (error || response.statusCode >= 300) {
            var err;

            if (error.code == "ECONNREFUSED") {
                err = "Could not connect to SPARQL endpoint.";
            }
            else {
                err = "SparQL query failed.";
            }

            continuation = nextTick(callback, [
                new Error(err),
                null
            ], that);
        }

carlostighe avatar Mar 12 '15 10:03 carlostighe