Ghost/core/server/errors/theme-validation-error.js
Hannah Wolfe 02ca986ed7 🎨 Improve theme validation error messaging (#7253)
refs #7204

- Adds a new ThemeValidationError class
- This error has a top level message, but will also contain all the individual errors within the `errorDetails` property
- Updated the API error handling to return `errorDetails` if it is present
2016-08-24 14:45:54 +02:00

19 lines
494 B
JavaScript

// # Theme Validation Error
// Custom error class with status code and type prefilled.
function ThemeValidationError(message, details) {
this.message = message;
this.stack = new Error().stack;
this.statusCode = 422;
if (details) {
this.errorDetails = details;
}
this.errorType = this.name;
}
ThemeValidationError.prototype = Object.create(Error.prototype);
ThemeValidationError.prototype.name = 'ThemeValidationError';
module.exports = ThemeValidationError;