Home/Tutorials/JavaScript/Error Handling

0 of 3 saved

JavaScript5 min read

Error Handling

Read this chapter, write the program on this page, then pass a short check to open the next one.

try, catch, throw, finally.

Error Handling

throw creates an error. try/catch recovers. In async functions, failed awaits reject into catch.

  • throw new Error("message")
  • finally always runs.
  • Do not swallow errors silently.
try {
  throw new Error("boom");
} catch (err) {
  console.log(err.message);
}

After you read this chapter, use Write (when available) and Quiz on this page to lock it in.