Skip to content

Incorrect username/password crashes program #3

@nerdenough

Description

@nerdenough

Using an incorrect username/password in the config causes the following error to occur:

SyntaxError: Unexpected end of input
    at Object.parse (native)
    at restCallbackHandler (...\node_modules\servicenow\servicenow.js:291:18)
    at Request._callback (...\node_modules\servicenow\servicenow.js:142:9)
    at Request.self.callback (...\node_modules\servicenow\node_modules\request\request.js:121:22)
    at emitTwo (events.js:87:13)
    at Request.emit (events.js:172:7)
    at Request.<anonymous> (...\node_modules\servicenow\node_modules\request\request.js:978:14)
    at emitOne (events.js:82:20)
    at Request.emit (events.js:169:7)
    at IncomingMessage.<anonymous> (...\node_modules\servicenow\node_modules\request\request.js:929:12)

npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v4.1.2
npm ERR! npm  v2.14.4
npm ERR! code ELIFECYCLE
npm ERR! start: `node app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the start script 'node app.js'.
npm ERR! This is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node app.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls ...
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     ...\npm-debug.log

I found that adding in a status code check into the restCallbackHandler function, similar to that in your jsonServiceErrorProcessor function fixed the issue.

e.g. something like:

if (response.statusCode != 200) {
    callback(response);
    return;
}

Placing that in the servicenow.js just before JSON.parse(body) on line 291 fixes the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions