Updated yaml parser error to be InvalidUsageError
- a yaml parser error can only be fixed by the user uploading a file, therefore it should be a 4xx, not a 5xx error - an amp parser error indicates the amperize module is unable to handle a genuine case, and needs to be fixed at the code level
This commit is contained in:
parent
1aa7e368a2
commit
cdb3b03311
@ -133,14 +133,16 @@ function getAmperizeHTML(html, post) {
|
||||
|
||||
if (err) {
|
||||
if (err.src) {
|
||||
// This is a valid 500 GhostError because it means the amperize parser is unable to handle some Ghost HTML.
|
||||
logging.error(new errors.GhostError({
|
||||
message: `AMP HTML couldn't get parsed: ${err.src}`,
|
||||
code: 'AMP_PARSER_ERROR',
|
||||
err: err,
|
||||
context: post.url,
|
||||
help: i18n.t('errors.apps.appWillNotBeLoaded.help')
|
||||
}));
|
||||
} else {
|
||||
logging.error(new errors.GhostError({err}));
|
||||
logging.error(new errors.GhostError({err, code: 'AMP_PARSER_ERROR'}));
|
||||
}
|
||||
|
||||
// save it in cache to prevent multiple calls to Amperize until
|
||||
|
@ -18,8 +18,10 @@ module.exports = function parseYaml(file, fileName) {
|
||||
} catch (error) {
|
||||
// CASE: parsing failed, `js-yaml` tells us exactly what and where in the
|
||||
// `reason` property as well as in the message.
|
||||
throw new common.errors.GhostError({
|
||||
// As the file uploaded is invalid, the person uploading must fix this - it's a 4xx error
|
||||
throw new common.errors.IncorrectUsageError({
|
||||
message: common.i18n.t('errors.services.settings.yaml.error', {file: fileName, context: error.reason}),
|
||||
code: 'YAML_PARSER_ERROR',
|
||||
context: error.message,
|
||||
err: error,
|
||||
help: common.i18n.t('errors.services.settings.yaml.help', {file: fileName})
|
||||
|
Loading…
Reference in New Issue
Block a user