Handling Errors
Let's see how error handling is done in RxJS.
As powerful as observables are, they can’t prevent errors from happening. Instead, they provide a concrete way to gracefully handle errors as they arise.
Error handling in subscribe
Errors are handled in the subscribe
call (same as regular data).
So far, the examples have only passed a single parameter to .subscribe
—a function that runs for every datum that arrives at the end of the stream.
Turns out, a total of three parameters can be passed in (the latter two being optional):
Get hands-on with 1400+ tech skills courses.