我正在使用node-horseman
来访问Google快讯并执行应用程序所需的操作,但我经常看到此错误,我发现无法解决此问题并中断操作并显示错误消息。
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)
有没有人知道如何抓住它?我尝试了.on('error')
并将其归还,但没有任何帮助。
答案 0 :(得分:0)
要抓住它就足够了:
.open()
在return reject(new Error(err.message))
之前
如果你像我一样使用Promise,你可以{{1}}