1localStorage.getItem(key)
2
3 try {
4 data = JSON.parse(key)
5 }
6 catch (e) {
7 // if the code errors, this bit of code will run
8 }
9 finally {
10
11 return data
12 }
1try {
2 myroutine(); // may throw three types of exceptions
3} catch (e) {
4 if (e instanceof TypeError) {
5 // statements to handle TypeError exceptions
6 } else if (e instanceof RangeError) {
7 // statements to handle RangeError exceptions
8 } else if (e instanceof EvalError) {
9 // statements to handle EvalError exceptions
10 } else {
11 // statements to handle any unspecified exceptions
12 logMyErrors(e); // pass exception object to error handler
13 }
14}
15