Throw Errors with RxJS Observables

InstructorAndré Staltz

Share this video with your friends

Send Tweet

Whenever we are writing code, we need to remember that things may go wrong. If an error happens in a function, that error will be thrown. Errors can also happen in Observables.

In this lesson we will see what the API is for throwing and catching Errors with Observables.

Voi Admin
~ 8 years ago

The final step wraps the setTimeout call in a try/catch block, however as I understand, if an error is thrown within the setTimeout, it will not be caught.

André Staltzinstructor
~ 8 years ago

Correct. The focus of this lesson was to demonstrate that errors can be caught inside Observable.create, and that you can pass those errors to the Observer. How those errors are actually caught is a different topic, and ideally I would place a try catch inside setTimeout too, and then pass those errors to the Observer as well.