While working with code from themes written in the latest Angular versions and doing research online, I've noticed that many developers neglect error handling when it comes to subscription
.
My question is: When is it necessary to handle errors in an Observable
subscription?
Without error handling:
this.myService.observable$.subscribe(
(data) => {
// do something with data
}
);
With error handling:
this.myService.observable$.subscribe(
(data) => {
// do something with data
},
err => {
// handle the error
}
);
I commonly see the first version being used, but...
Could neglecting error handling be a problem in a subscription?
Wouldn't this approach result in less robust, less testable code that is more likely to fail?