Ghost/core/server/errors/validation-error.js

18 lines
477 B
JavaScript
Raw Normal View History

// # 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;
}
this.type = this.name;
}
ValidationError.prototype = Object.create(Error.prototype);
ValidationError.prototype.name = 'ValidationError';
2014-06-12 23:54:01 +04:00
module.exports = ValidationError;