Removed redundant errorDetail and context stringification in errors (#10572)

no issue

- Additional JSON.stringify call is redundant because it is already happening internally in Ignition (https://github.com/TryGhost/Ignition/blob/master/lib/logging/GhostLogger.js#L241)
- Left stringification in importer as is, because the use case there is also
putting errors into 'problems' array and seems like those values have to
be stringified
This commit is contained in:
Naz Gargol 2019-03-07 12:58:44 +08:00 committed by GitHub
parent 4428ed5f79
commit 9810834f7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -372,7 +372,7 @@ validateRedirects = function validateRedirects(redirects) {
if (!redirect.from || !redirect.to) { if (!redirect.from || !redirect.to) {
throw new common.errors.ValidationError({ throw new common.errors.ValidationError({
message: common.i18n.t('errors.utils.redirectsWrongFormat'), message: common.i18n.t('errors.utils.redirectsWrongFormat'),
context: JSON.stringify(redirect), context: redirect,
help: 'https://docs.ghost.org/concepts/redirects/' help: 'https://docs.ghost.org/concepts/redirects/'
}); });
} }

View File

@ -63,11 +63,11 @@ module.exports = function (Bookshelf) {
message: 'Saving failed! Someone else is editing this post.', message: 'Saving failed! Someone else is editing this post.',
code: 'UPDATE_COLLISION', code: 'UPDATE_COLLISION',
level: 'critical', level: 'critical',
context: JSON.stringify({ context: {
clientUpdatedAt: self.clientData.updated_at, clientUpdatedAt: self.clientData.updated_at,
serverUpdatedAt: self.serverData.updated_at, serverUpdatedAt: self.serverData.updated_at,
changed: changed changed: changed
}) }
})); }));
} }
} }

View File

@ -38,7 +38,7 @@ module.exports = {
common.logging.warn(new common.errors.ThemeValidationError({ common.logging.warn(new common.errors.ThemeValidationError({
errorType: 'ThemeWorksButHasErrors', errorType: 'ThemeWorksButHasErrors',
message: common.i18n.t('errors.middleware.themehandler.themeHasErrors', {theme: activeThemeName}), message: common.i18n.t('errors.middleware.themehandler.themeHasErrors', {theme: activeThemeName}),
errorDetails: JSON.stringify(checkedTheme.results.error, null, '\t') errorDetails: checkedTheme.results.error
})); }));
} }
@ -49,7 +49,7 @@ module.exports = {
if (err.errorDetails) { if (err.errorDetails) {
common.logging.error(new common.errors.ThemeValidationError({ common.logging.error(new common.errors.ThemeValidationError({
message: common.i18n.t('errors.middleware.themehandler.invalidTheme', {theme: activeThemeName}), message: common.i18n.t('errors.middleware.themehandler.invalidTheme', {theme: activeThemeName}),
errorDetails: JSON.stringify(err.errorDetails, null, '\t') errorDetails: err.errorDetails
})); }));
} }