1
0
mirror of synced 2025-12-21 10:57:10 -05:00
Files
docs/middleware/trigger-error.js
Kevin Heis 8a56437c93 Pretty format (#20352)
* Update prettier flow to include JS

* Run prettier

* ...run prettier
2021-07-14 14:35:01 -07:00

14 lines
550 B
JavaScript

// This module is for testing our handling of uncaught async rejections on incoming requests
// IMPORTANT: Leave this function as `async` even though it doesn't need to be!
export default async function triggerError(req, res, next) {
// IMPORTANT:
// Do NOT wrap this method's contents in the usual `try-catch+next(error)`
// pattern used on async middleware! This is an intentional omission!
// prevent this from being used in production
if (process.env.NODE_ENV === 'production') return next()
throw new Error('Intentional error')
}