Javascript try/catch - Error Properties (Reference)
There are two basic properties which is used to handle errors in JavaScript try/catch. One is error name and other is error message.
name
The name property of error object is used to store the name of the error.
try {
xalert("fallinfo");
} catch (err) {
var x = err.name;
// ReferenceError
}
// EvalError An error in the eval(). Newer JS does not throw any EvalError.
// RangeError A number "out of range"
// ReferenceError An illegal reference
// SyntaxError A syntax error
// TypeError A type error
// URIError An error in encodeURI()
message
The message property of error object is used to store the message of the error.
try {
xalert("fallinfo");
} catch (err) {
var x = err.message;
// xalert is not defined
}
