0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

🐛 Fixed handling of Handlebars errors

no issue

- Handlebars now throws an Error for misuse errors within the if/unless
  helpers, but our error handling checks for a TypeError
- this would skip using an IncorrectUsageError and ends up throwing a GhostError
- this commit removes the TypeError check and switches to using the
  Handlebars error message
This commit is contained in:
Daniel Lockyer 2020-04-29 16:17:12 +01:00
parent a72c4e7905
commit 6d21bbfc63

View file

@ -41,12 +41,12 @@ _private.prepareError = (err, req, res, next) => {
err = new errors.NotFoundError({ err = new errors.NotFoundError({
err: err err: err
}); });
} else if (err instanceof TypeError && err.stack.match(/node_modules\/handlebars\//)) { } else if (err.stack.match(/node_modules\/handlebars\//)) {
// Temporary handling of theme errors from handlebars // Temporary handling of theme errors from handlebars
// @TODO remove this when #10496 is solved properly // @TODO remove this when #10496 is solved properly
err = new errors.IncorrectUsageError({ err = new errors.IncorrectUsageError({
err: err, err: err,
message: '{{#if}} or {{#unless}} helper is malformed', message: err.message,
statusCode: err.statusCode statusCode: err.statusCode
}); });
} else { } else {