0
我使用node-horseman
訪問Google快訊並執行應用程序所需的操作,但我經常看到這種我認爲無用的錯誤解決方案來捕獲並中斷操作並顯示錯誤消息。未處理的拒絕錯誤:無法獲取網址:https://google.com/alerts
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')
並返回它,但沒有任何幫助。
請,告訴你如何試圖抓住排斥反應。我認爲騎士用承諾取代回調? – Vaviloff
我已經知道如何正確地抓住它,儘管我不知道它爲什麼會一直在發生。它決定去做。 @ ##%4 PhantomJS。 – mfgabriel92
馬術諾言鏈中是否有'.catch'方法?如果我沒有弄錯,通常它會用來捕捉未處理的錯誤? – Vaviloff