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