The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Observables can throw errors

Observables can throw errors

1:39
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, and in this lesson we will see what is the API for throwing and catching them.
Watch this lesson now
Avatar
egghead.io

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, and in this lesson we will see what is the API for throwing and catching them.

Avatar
Admin

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.

Avatar
Andre

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.

In reply to Admin
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?