有沒有一種很好的方法來捕獲有關連接問題的Angular中的錯誤?
服務$ HTTP POST:
dossierService.getDossier(uid)
.then(function (result) {
vm.dossier = result.dossier;
}, function (error) {
handleError(error)
});//end dossierService.getDossier(uid)
如果出現連接問題,它會返回一個錯誤:
POST http://192.168.25.1:8080/api/query net::ERR_CONNECTION_TIMED_OUT
我怎樣才能顯示正確的信息給用戶,讓他/她知道確切的錯誤是什麼?
的可能的複製[在角$ http服務,我怎麼能捕獲錯誤的 「地位」?](http://stackoverflow.com/questions/27507678/in-angular-http-service-how-can-i-catch-the-status-of-error) –
更好的使用try/catch throw的方法 – amoeba
爲什麼是@amoeba? – maurycy