Skip to main content

JavaScript Errors

8 lessonsAbout 48 minutesAdvanced

This part of the JavaScript Tutorial runs from JavaScript Errors through to JavaScript Debugging. There are 8 lessons here, and working through them takes about 48 minutes at a steady pace.

It follows on from JavaScript Numbers & Math, so finish that first if you have not already — the examples below assume you are comfortable with it.

Each lesson below says what it covers before you open it. Read them in order the first time; afterwards this page works as a index you can jump back into when you need to check one thing.

  1. 1JavaScript ErrorsAn error stops the current code and travels up until something handles it.
  2. 2JavaScript try catchtry runs code that might fail, and catch handles it when it does.
  3. 3JavaScript throwthrow raises an error deliberately when something is wrong.
  4. 4JavaScript finallyfinally runs whether the code succeeded or failed.
  5. 5JavaScript Error TypesJavaScript has several built-in error types, each describing a different kind of failure.
  6. 6JavaScript Custom ErrorsA custom error class describes a failure specific to your own program.
  7. 7JavaScript Error Handling PatternsGood error handling is about deciding where a failure should be dealt with.
  8. 8JavaScript DebuggingDebugging is the process of finding out why code does not do what you expected.