Bummer! This is just a preview. You need to be signed in with an account to view the entire instruction.

Well done!

You have completed (UPI) Chapter 11: Managing Errors, Debugging, and Handling Events in JavaScript!

Instruction

Conditional catch blocks

You can create "Conditional catch blocks" by combining try...catch blocks with if...else if...else structures, like this:


Example

try {
  myroutine(); // may throw three types of exceptions
} catch (e) {
  if (e instanceof TypeError) {
    // statements to handle TypeError exceptions
  } else if (e instanceof RangeError) {
    // statements to handle RangeError exc...