I want to catch all http errors to inform the user of an occurred problem.
So, I created a method that does a http get with a catch.
get(path: string): Promise<any> {
let headers = new Headers();
return this.http.get(path, { headers: headers })
.toPromise()
.then(response => { ... })
.catch((response: Response) => { this.errorHandler(response); });
}
When the path parameter is '/fault-url' the catch is handled as expected.
But when the path is 'http://localhost:5000/fault-url' the error is not catched by the catch method. I've added logging to all different places, but it seams the get method just aborts. The console log shows following errors
OPTIONS http://localhost:5000/fault-url net::ERR_CONNECTION_REFUSED
EXCEPTION: Response with status: 0 for URL: null
Uncaught Response {_body: ProgressEvent, status: 0, ok: false, statusText: "", headers: Headers…}
Does http realy abort or am i doing something wrong?
After upgrading to Angular 2.3.0 the problem is solved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With