Skip to content

responseHandler - no error but response.statusCode > 300  #9

@carlostighe

Description

@carlostighe

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);
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions