有没有一种很好的方法来捕获有关连接问题的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