The error objects created by constructors(Error(), SyntaxError(), TypeError(), and others) have the following properties:
name
The name property of the constructor function that created the object; it could be the general “Error” or a more specialized constructor such as “RangeError”.
message
The string passed to the constructor when creating the object.
You can be creative when it comes to your custom error objects and use them to restore the application state back to normal.
try { // something bad happened, throw an error throw { name: "MyErrorType", // custom error type message: "oops", extra: "This was rather embarrassing", remedy: genericErrorHandler // who should handle it }; } catch (e) { // inform the user alert(e.message); // "oops" // gracefully handle the error e.remedy(); // calls genericErrorHandler() }