Created
December 30, 2009 18:38
-
-
Save kusor/266275 to your computer and use it in GitHub Desktop.
Custom JavaScript Error
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
$ ./bin/js | |
js> function ResourceValidationError() { | |
Error.apply(this, arguments); | |
if (arguments.length >= 1) { | |
this.message = arguments[0]; | |
} | |
} | |
js> ResourceValidationError.prototype = new Error(); | |
Error | |
js> ResourceValidationError.prototype.constructor = ResourceValidationError; | |
function ResourceValidationError() { | |
Error.apply(this, arguments); | |
if (arguments.length >= 1) { | |
this.message = arguments[0]; | |
} | |
} | |
js> ResourceValidationError.prototype.name = 'ResourceValidationError'; | |
ResourceValidationError | |
js> try { | |
throw new ResourceValidationError('this.foo is required'); | |
} catch(e) { | |
if (e.name == 'ResourceValidationError'){ | |
e.message; | |
} | |
} | |
this.foo is required | |
js> |
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
function ResourceValidationError() { | |
Error.apply(this, arguments); | |
if (arguments.length >= 1) { | |
this.message = arguments[0]; | |
} | |
} | |
ResourceValidationError.prototype = new Error(); | |
ResourceValidationError.prototype.constructor = ResourceValidationError; | |
ResourceValidationError.prototype.name = 'ResourceValidationError'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment