Answers for "try catch finally example"

0

try-catch-finally

localStorage.getItem(key)

    try {
        data = JSON.parse(key)
    }
    catch (e) {
        // if the code errors, this bit of code will run
    }
    finally {
    
        return data
    }
Posted by: Guest on April-26-2021
0

try catch finally 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 exceptions
  } else if (e instanceof EvalError) {
    // statements to handle EvalError exceptions
  } else {
    // statements to handle any unspecified exceptions
    logMyErrors(e); // pass exception object to error handler
  }
}
Posted by: Guest on June-08-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language