1
0
mirror of synced 2025-12-20 02:19:14 -05:00

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:
Mike Surowiec
2021-07-21 15:22:30 -04:00
committed by GitHub
parent a0eff64e4f
commit df38087aed
10 changed files with 181 additions and 342 deletions

View File

@@ -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)