Brainlag
  1. Web
  2. Data and the network
29/38 lessons

Handling errors on purpose

35 min4 exercisesPremium

Throw your own errors, catch them with try, catch and finally, and keep a page working when JSON is broken or a server answers with an error.

The skill
Throw, catch and recover from errors so one failure does not break the app.
You make
An age checker, a safe save loader and a news feed that survives a broken server.

Premium lesson

£7.99 a month or £59 a year. Cancel any time.

Builds on 28 fetch and APIs. Free to try: Web Foundations and the playground.

Step 1 of 8
exercise_1.js

You've reached the good stuff.

4 exercises in this lesson, checked as you type. Premium opens every lesson after Foundations, in all four courses.

JavaScript