Clarify error handlers are final and don't call next() (#7646)

This commit is contained in:
XIN_____ 2026-01-27 19:05:25 -06:00 committed by GitHub
parent 3c0b449c6e
commit e90504b8cf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -28,6 +28,12 @@ export const errorHasCode = (error: any): error is ErrorWithCode => {
const notFoundCodes = [404, "ENOENT", "EISDIR"]
/**
* Final HTTP error handler.
*
* Note: This handler intentionally does not call `next()` even though it
* accepts it as an argument; it is expected to be mounted last.
*/
export const errorHandler: express.ErrorRequestHandler = async (err, req, res, next) => {
let statusCode = 500
@ -61,6 +67,12 @@ export const errorHandler: express.ErrorRequestHandler = async (err, req, res, n
}
}
/**
* Final WebSocket error handler.
*
* Note: This handler intentionally does not call `next()` even though it
* accepts it as an argument; it is expected to be mounted last.
*/
export const wsErrorHandler: express.ErrorRequestHandler = async (err, req, res, next) => {
let statusCode = 500
if (errorHasStatusCode(err)) {