forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrigger-error.js
More file actions
13 lines (10 loc) · 550 Bytes
/
trigger-error.js
File metadata and controls
13 lines (10 loc) · 550 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
// 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')
}