0 votes
in Angular by
How do you deal with errors in observables in Angular?

1 Answer

0 votes
by

Instead of depending on try/catch, which is useless in an asynchronous context, you may manage problems by setting an error callback on the observer.

Example: You may create an error callback as shown below.

myObservable.subscribe({
    next(number) { console.log('Next number: ' + number)},
    error(err) { console.log('An error received ' + err)}
  });
...