

Lesson 09 · 10 min
Errors: throw, try/catch, cause
An error isn't the end of the world if you know where to catch it.
10 minLesson 9 of 10Practice includedAsk AI on any point
There are two kinds of errors. Expected ones — the file is missing, the network is down, the user typed nonsense: you catch and handle them. Bugs — undefined is not a function: you don't hide them, you fix them. In async code, throw rejects the Promise, and try/catch around await catches it. Your own error class with a code or status field lets you tell one from another.
Sign in to continue
The rest of this lesson opens after sign up
The first lesson of every course is open without an account. To read on, solve the practice and use Ask, create a free account or log in.