0
コードでは、私のhttp要求をインターセプトしようとしています。私がhttp接続を確立することができるときはいつも、私のインターセプターは動作しますが、net::ERR_CONNECTION_REFUSED
を受け取ったとき、event
の変数はHttpResponse
のインスタンスではないので、この種のエラーは処理できません。ここに私のコードは次のとおりです。角度4 - インターセプタハンドルnet :: ERR_CONNECTION_REFUSED
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
this.changeStatus(false);
this.requests_count++;
const my_req = req.clone({
url: API_PATH + req.url
});
return next
.handle(my_req)
.do(event => {
if (event instanceof HttpResponse) {
this.requests_count--;
if (!this.requests_count)
this.changeStatus(true);
}
});
}
私はnet::ERR_CONNECTION_REFUSED
のような迎撃エラーに検出することができますどのように?