Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/node/routes/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)) {
Expand Down