ngx-translate/http-loader

Support for error handling from `http.get`

ajcrites opened this issue · 3 comments

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

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.

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.

we need this