Created
January 21, 2015 20:01
-
-
Save ezmiller/39ccfa40a1349b1709c3 to your computer and use it in GitHub Desktop.
One way to create globally available custom errors as a service in SailsJS
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
'use strict'; | |
/** | |
* Indicates an error where an invalid argument or input to a method. | |
* @param {string} message The error message. | |
* @param {string} stack The stack trace. | |
*/ | |
function InvalidArgumentException(message, stack) { | |
this.name = 'InvalidArgumentException'; | |
this.message = message || 'Invalid Argument'; | |
this.stack = stack; | |
} | |
InvalidArgumentException.prototype = new Error(); | |
InvalidArgumentException.prototype.constructor = InvalidArgumentException; | |
module.exports = { | |
InvalidArgumentException: InvalidArgumentException | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You'd place this file in your
api/services
directory, and then you would the do this later on: