HttpClient error code/message reporting

I’m having problems getting meaningful HttpClient error messages out so I can log/report them. I have a provider with code similar to:

constructor(public http: HttpClient) {}

getData() {
    return this.http.get<Item[]>(this.url)

private handleError(error: HttpErrorResponse) {
    let errmsg:string;
    if (error.error instanceof ErrorEvent) {
        errmsg = `client/network error: ${error.error.message}`;
    } else {
        errmsg = `server error: ${error.status}: ${error.error}`;
    return new ErrorObservable(errmsg);

Running app with ionic serve, works under normal conditions but when I stop my Tomcat server to force an error any useful diagnostic info gets lost before it gets to handleError(). Javascript console shows:

GET https... net::ERROR_CONNECTION_REFUSED (at polyfills.js:3)

The handleError() console message from the JSON.stringify() shows

status: 0
statusText: Unknown Error
name: HttpErrorResponse
message: Http failure response for (unknown url): 0 Unknown Error

The console.error(errmsg) at the end of handleError() produces:

server error 0: [object ProgressEvent]

What am I missing? How can I get a proper error code/message in my hands that I can do something useful with?


Did you get a solution ?