javascript return error from catch code example
Example 1: try catch javascript
try {
// code may cause error
} catch(error){
// code to handle error
}
Example 2: try catch throwing error in javascript
let json = '{ "age": 30 }'; // incomplete data
try {
let user = JSON.parse(json); // <-- no errors
alert( user.name ); // no name!
} catch (e) {
alert( "doesn't execute" );
}