0 votes
in Angular by

How do you perform error handling in observables?

1 Answer

0 votes
by
You can handle errors by specifying an error callback on the observer instead of relying on try/catch, which are ineffective in asynchronous environment.

For example, you can define error callback as below,

myObservable.subscribe({

  next(num) { console.log('Next num: ' + num)},

  error(err) { console.log('Received an errror: ' + err)}

});

Related questions

0 votes
asked Jun 26, 2022 in Django by john ganales
0 votes
asked Mar 28, 2021 in Testing by rajeshsharma
...