try catch exception message javascript code example
Example 1: catch error message js
try {
// test code
} catch (error) { // if error
console.error(error); // return error
}
Example 2: javascript try
var someNumber = 1;
try {
someNumber.replace("-",""); //You can't replace a int
} catch(err) {
console.log(err);
}