2014-05-09 05:11:29 -05:00
|
|
|
// # Validation Error
|
|
|
|
// Custom error class with status code and type prefilled.
|
|
|
|
|
|
|
|
function ValidationError(message, offendingProperty) {
|
|
|
|
this.message = message;
|
|
|
|
this.stack = new Error().stack;
|
2016-02-17 09:51:57 -05:00
|
|
|
this.statusCode = 422;
|
2014-05-09 05:11:29 -05:00
|
|
|
if (offendingProperty) {
|
|
|
|
this.property = offendingProperty;
|
|
|
|
}
|
2015-04-22 15:29:45 -05:00
|
|
|
this.errorType = this.name;
|
2014-05-09 05:11:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
ValidationError.prototype = Object.create(Error.prototype);
|
2014-07-02 09:22:18 -05:00
|
|
|
ValidationError.prototype.name = 'ValidationError';
|
2014-05-09 05:11:29 -05:00
|
|
|
|
2014-06-12 14:54:01 -05:00
|
|
|
module.exports = ValidationError;
|