mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Moved JSON error handlers next to each other
- helps for comparing and contrasting - context is largely lost on why we have these two, need to figure it out and if possible, simplify
This commit is contained in:
parent
f417c4c732
commit
0c4c9ce553
1 changed files with 17 additions and 17 deletions
|
@ -123,6 +123,23 @@ _private.JSONErrorRenderer = (err, req, res, next) => { // eslint-disable-line n
|
|||
});
|
||||
};
|
||||
|
||||
_private.JSONErrorRendererV2 = (err, req, res, next) => { // eslint-disable-line no-unused-vars
|
||||
const userError = _private.prepareUserMessage(err, req);
|
||||
|
||||
res.json({
|
||||
errors: [{
|
||||
message: userError.message || null,
|
||||
context: userError.context || null,
|
||||
type: err.errorType || null,
|
||||
details: err.errorDetails || null,
|
||||
property: err.property || null,
|
||||
help: err.help || null,
|
||||
code: err.code || null,
|
||||
id: err.id || null
|
||||
}]
|
||||
});
|
||||
};
|
||||
|
||||
_private.prepareUserMessage = (err, res) => {
|
||||
const userError = {
|
||||
message: err.message,
|
||||
|
@ -169,23 +186,6 @@ _private.prepareUserMessage = (err, res) => {
|
|||
return userError;
|
||||
};
|
||||
|
||||
_private.JSONErrorRendererV2 = (err, req, res, next) => { // eslint-disable-line no-unused-vars
|
||||
const userError = _private.prepareUserMessage(err, req);
|
||||
|
||||
res.json({
|
||||
errors: [{
|
||||
message: userError.message || null,
|
||||
context: userError.context || null,
|
||||
type: err.errorType || null,
|
||||
details: err.errorDetails || null,
|
||||
property: err.property || null,
|
||||
help: err.help || null,
|
||||
code: err.code || null,
|
||||
id: err.id || null
|
||||
}]
|
||||
});
|
||||
};
|
||||
|
||||
_private.ErrorFallbackMessage = err => `<h1>${tpl(messages.oopsErrorTemplateHasError)}</h1>
|
||||
<p>${tpl(messages.encounteredError)}</p>
|
||||
<pre>${escapeExpression(err.message || err)}</pre>
|
||||
|
|
Loading…
Reference in a new issue