Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Support for error handling from http.get #29

Open
ajcrites opened this issue Sep 20, 2017 · 3 comments
Open

Support for error handling from http.get #29

ajcrites opened this issue Sep 20, 2017 · 3 comments

Comments

@ajcrites
Copy link

ajcrites commented Sep 20, 2017

Currently if there are any errors from http.get (e.g. the file does not exist) the error is propagated to the top level of the app and there's no way to catch it.

I suggest support for adding an error handler function -- something like:

    constructor(private http: HttpClient, public prefix: string = "/assets/i18n/", public suffix: string = ".json", public errorHandler?: () => any) {}

    public getTranslation(lang: string): any {
      const obs = this.http.get(url);
      if (this.errorHandler) {
        obs.catch(this.errorHandler);
      }

      return obs;
    }
@NiklasMerz
Copy link

I have also encountered the same problem. This is reproducable if you pass an locale to translate.use which has no translations file. This raises an http error but the error part of the Observable of translate.use is not called.

@chris13524
Copy link

I also would love to have support for catching errors. We have a global error handler that sends all global errors to us.

We would like to be able to catch errors originating from this and display an appropriate error message.

@orcunozbay1
Copy link

orcunozbay1 commented Jun 17, 2020

we need this

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants