Update 404/500 pages to no longer use liquid templates (#20450)
* Update 404/500 page rendering to no longer use liquid templates * updating tests * remove unused path Co-authored-by: Grace Park <gracepark@github.com>
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import { liquid } from '../lib/render-content/index.js'
|
||||
import FailBot from '../lib/failbot.js'
|
||||
import loadSiteData from '../lib/site-data.js'
|
||||
import builtAssets from '../lib/built-asset-urls.js'
|
||||
import { nextApp } from './next.js'
|
||||
|
||||
function shouldLogException(error) {
|
||||
const IGNORED_ERRORS = [
|
||||
@@ -54,15 +52,7 @@ export default async function handleError(error, req, res, next) {
|
||||
|
||||
// Special handling for when a middleware calls `next(404)`
|
||||
if (error === 404) {
|
||||
// Again, we can remove this once the 404/500 pages are ready
|
||||
return res
|
||||
.status(404)
|
||||
.send(
|
||||
await liquid.parseAndRender(
|
||||
fs.readFileSync(path.join(process.cwd(), './layouts/error-404.html'), 'utf8'),
|
||||
req.context
|
||||
)
|
||||
)
|
||||
return nextApp.render404(req, res)
|
||||
}
|
||||
|
||||
// If the error contains a status code, just send that back. This is usually
|
||||
@@ -75,15 +65,9 @@ export default async function handleError(error, req, res, next) {
|
||||
console.error('500 error!', req.path)
|
||||
console.error(error)
|
||||
}
|
||||
// Again, we can remove this once the 404/500 pages are ready
|
||||
res
|
||||
.status(500)
|
||||
.send(
|
||||
await liquid.parseAndRender(
|
||||
fs.readFileSync(path.join(process.cwd(), './layouts/error-500.html'), 'utf8'),
|
||||
req.context
|
||||
)
|
||||
)
|
||||
|
||||
res.statusCode = 500
|
||||
nextApp.renderError(error, req, res, req.path)
|
||||
|
||||
// Report to Failbot AFTER responding to the user
|
||||
await logException(error, req)
|
||||
|
||||
Reference in New Issue
Block a user