Unhandled rejection Error: Failed to GET url: https://google.com/alerts

514 Views Asked by At

I'm using node-horseman to access Google Alerts and perform actions required by the application, but I often see this error of which I find no helpful solution to catch this and interrupt the operation and showing an error message.

Unhandled rejection Error: Failed to GET url: https://google.com/alerts
    at checkStatus (/home/gabriel/Sites/co-report-stable/api/node_modules/node-horseman/lib/actions.js:78:16)
    at PassThroughHandlerContext.finallyHandler (/home/gabriel/Sites/co-report-stable/api/node_modules/bluebird/js/release/finally.js:56:23)
    at PassThroughHandlerContext.tryCatcher (/home/gabriel/Sites/co-report-stable/api/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/gabriel/Sites/co-report-stable/api/node_modules/bluebird/js/release/promise.js:510:31)
    at Promise._settlePromise (/home/gabriel/Sites/co-report-stable/api/node_modules/bluebird/js/release/promise.js:567:18)
    at Promise._settlePromise0 (/home/gabriel/Sites/co-report-stable/api/node_modules/bluebird/js/release/promise.js:612:10)
    at Promise._settlePromises (/home/gabriel/Sites/co-report-stable/api/node_modules/bluebird/js/release/promise.js:691:18)
    at Promise._fulfill (/home/gabriel/Sites/co-report-stable/api/node_modules/bluebird/js/release/promise.js:636:18)
    at /home/gabriel/Sites/co-report-stable/api/node_modules/bluebird/js/release/nodeback.js:42:21
    at /home/gabriel/Sites/co-report-stable/api/node_modules/node-phantom-simple/node-phantom-simple.js:60:18
    at IncomingMessage.<anonymous> (/home/gabriel/Sites/co-report-stable/api/node_modules/node-phantom-simple/node-phantom-simple.js:645:9)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:975:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Does anyone have any idea on how to catch it? I tried .on('error') and return it, but nothing helps.

1

There are 1 best solutions below

0
AudioBubble On BEST ANSWER

To catch it this is enough:

.on('resourceError', function(err) {
    console.log(err.message)
})

Before .open()

If you're using Promise as me, you can return reject(new Error(err.message))