mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +03:00
🐛 fixed error message code for HB translate helper (#15529)
closes: https://github.com/TryGhost/Ghost/issues/15500 - Per the issue, Ghost has a policy to never throw 500 Internal Server errors for theme issues. This change adds a check inside of `ghost\core\core\frontend\helpers\t.js` if `text` or `options` is undefined, to throw an `IncorrectUsageError` error within the function. - Messaging was borrowed from `ghost\core\core\frontend\web\middleware\error-handler.js`.
This commit is contained in:
parent
8374c73e52
commit
87d21662bc
@ -11,8 +11,20 @@
|
||||
// {{tags prefix=(t " on ")}}
|
||||
|
||||
const {themeI18n} = require('../services/handlebars');
|
||||
const errors = require('@tryghost/errors');
|
||||
const tpl = require('@tryghost/tpl');
|
||||
|
||||
const messages = {
|
||||
oopsErrorTemplateHasError: 'Oops, seems there is an error in the template.'
|
||||
};
|
||||
|
||||
module.exports = function t(text, options) {
|
||||
if (text === undefined && options === undefined) {
|
||||
throw new errors.IncorrectUsageError({
|
||||
message: tpl(messages.oopsErrorTemplateHasError)
|
||||
});
|
||||
}
|
||||
|
||||
const bindings = {};
|
||||
let prop;
|
||||
for (prop in options.hash) {
|
||||
|
Loading…
Reference in New Issue
Block a user