Skip to content

Commit 7089273

Browse files
committed
Added error handling for weird handlebars syntax
refs #10496 - handlebars if and unless helpers throw weird, unhelpful syntax errors - for now, catch these errors and do something helpful with them
1 parent 9abffe4 commit 7089273

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

core/server/web/shared/middlewares/error-handler.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ _private.prepareError = (err, req, res, next) => {
3939
err = new common.errors.NotFoundError({
4040
err: err
4141
});
42+
} else if (err instanceof TypeError && err.stack.match(/node_modules\/handlebars\//)) {
43+
// Temporary handling of theme errors from handlebars
44+
// @TODO remove this when #10496 is solved properly
45+
err = new common.errors.IncorrectUsageError({
46+
err: err,
47+
message: '{{#if}} or {{#unless}} helper is malformed',
48+
statusCode: err.statusCode
49+
});
4250
} else {
4351
err = new common.errors.GhostError({
4452
err: err,

0 commit comments

Comments
 (0)