1
0
mirror of synced 2025-12-21 10:57:10 -05:00

Pretty format (#20352)

* Update prettier flow to include JS

* Run prettier

* ...run prettier
This commit is contained in:
Kevin Heis
2021-07-14 14:35:01 -07:00
committed by GitHub
parent ae3db795f4
commit 8a56437c93
333 changed files with 6904 additions and 5350 deletions

View File

@@ -4,12 +4,12 @@ import FailBot from '../lib/failbot.js'
import loadSiteData from '../lib/site-data.js'
import builtAssets from '../lib/built-asset-urls.js'
function shouldLogException (error) {
function shouldLogException(error) {
const IGNORED_ERRORS = [
// avoid sending CSRF token errors (from bad-actor POST requests)
'EBADCSRFTOKEN',
// Client connected aborted
'ECONNRESET'
'ECONNRESET',
]
if (IGNORED_ERRORS.includes(error.code)) {
@@ -20,15 +20,15 @@ function shouldLogException (error) {
return true
}
async function logException (error, req) {
async function logException(error, req) {
if (process.env.NODE_ENV !== 'test' && shouldLogException(error)) {
await FailBot.report(error, {
path: req.path
path: req.path,
})
}
}
export default async function handleError (error, req, res, next) {
export default async function handleError(error, req, res, next) {
try {
// If the headers have already been sent or the request was aborted...
if (res.headersSent || req.aborted) {
@@ -53,9 +53,7 @@ export default async function handleError (error, req, res, next) {
// Special handling for when a middleware calls `next(404)`
if (error === 404) {
return res
.status(404)
.send(await liquid.parseAndRender(layouts['error-404'], req.context))
return res.status(404).send(await liquid.parseAndRender(layouts['error-404'], req.context))
}
// If the error contains a status code, just send that back. This is usually