Created
October 4, 2013 08:04
-
-
Save dannycallaghan/6822539 to your computer and use it in GitHub Desktop.
Error Object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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