Errors in JavaScript

Errors in JavaScript: Handling Errors with try, catch and finally, Throwing Your Own Errors.

Updated

  1. Handling Errors with try, catch and finally (Apprentice): try runs code that might fail, catch takes over when it does and gets an error object with a name and a message, and finally runs either way, so one bad value doesn't stop your whole program.
  2. Throwing Your Own Errors (Journeyman): When a function gets a value it can't use, throw new Error with a message that says what was wrong, make your own error class with extends Error for the problems your program knows about, and return a value instead when there's no mistake to report.