Skip to content

Instantly share code, notes, and snippets.

@dannycallaghan
Created October 4, 2013 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dannycallaghan/6822539 to your computer and use it in GitHub Desktop.
Save dannycallaghan/6822539 to your computer and use it in GitHub Desktop.
Error Object
/* The Error Object */
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()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment