Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Http does not catch connection refused error #2951

@tsluijter

Description

@tsluijter

Hi,

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 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…}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions