mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-01 23:37:43 +03:00
Removed unnecessary BasicErrorRenderer
refs:4474ca1a1d
refs:0799f02e80
The BasicErrorRenderer was created as a fallback for when we needed to not render templates, which is chiefly when we're trying to render a 404 for an image. Using a template puts us at risk of an infinite 404 loop if the missing image is referenced in the 404 template. As of0799f02e
, the HTMLErrorRenderer no longer uses templates - instead we serve a very simple HTML page. This can be used instead of the BasicErrorRenderer, as it results in a properly formatted error. Even when sending responses in plain text, the content type is returned as HTML and therefore having an unformatted error makes no sense - if we really need a non-html format I guess there should be no body at all.
This commit is contained in:
parent
449c61bb1b
commit
8c93bdff41
@ -289,10 +289,6 @@ _private.HTMLErrorRenderer = (err, req, res, next) => { // eslint-disable-line n
|
||||
return res.send(createHtmlDocument(res.statusCode, err.stack));
|
||||
};
|
||||
|
||||
_private.BasicErrorRenderer = (err, req, res, next) => { // eslint-disable-line no-unused-vars
|
||||
return res.send(res.statusCode + ' ' + err.stack);
|
||||
};
|
||||
|
||||
errorHandler.resourceNotFound = (req, res, next) => {
|
||||
// TODO, handle unknown resources & methods differently, so that we can also produce
|
||||
// 405 Method Not Allowed
|
||||
@ -327,9 +323,7 @@ errorHandler.handleHTMLResponse = [
|
||||
// Handle the error in Sentry
|
||||
sentry.errorHandler,
|
||||
// Render the error using HTML format
|
||||
_private.HTMLErrorRenderer,
|
||||
// Fall back to basic if HTML is not explicitly accepted
|
||||
_private.BasicErrorRenderer
|
||||
_private.HTMLErrorRenderer
|
||||
];
|
||||
|
||||
errorHandler.handleThemeResponse = [
|
||||
@ -340,7 +334,7 @@ errorHandler.handleThemeResponse = [
|
||||
// Render the error using theme template
|
||||
_private.ThemeErrorRenderer,
|
||||
// Fall back to basic if HTML is not explicitly accepted
|
||||
_private.BasicErrorRenderer
|
||||
_private.HTMLErrorRenderer
|
||||
];
|
||||
|
||||
module.exports = errorHandler;
|
||||
|
Loading…
Reference in New Issue
Block a user