Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix: uncaught error within TranslateService.use() #827

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sagittarius-rev
Copy link

When use the use() method of TranslateService to load an invalid language, it will result nothing. For example, the file assets/i18n/vvvv.json does not exist, so the "vvvv" language is invalid:

this.translateService.use('vvvv').pipe(
  mapTo(true),
  catchError(() => Observable.of(false)),
).subscribe((isSuccess: boolean) => console.warn('isSuccess: ', isSuccess));

The code above will not output anything.

Because there is an uncaught error within the use() method:

      pending.pipe(take(1))
        .subscribe((res: any) => {
          this.changeLang(lang);
        });

If the language file is missing, this code will break the running, the other subscribers of pending will be halt, missing the data of next(), error() or complete().

Adding a void error handler will fix this bug.

@ocombe
Copy link
Member

ocombe commented Feb 5, 2020

Hello, could you rebase your PR and add a test for that change please? thanks

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

Successfully merging this pull request may close these issues.

3 participants