From 774de359bb882d8d2931d2feb470a6b16f060fda Mon Sep 17 00:00:00 2001 From: Guido de Jong <35309288+guidojw@users.noreply.github.com> Date: Sat, 7 Sep 2024 16:19:02 +0200 Subject: [PATCH] fix(expressLoader): log errors above status 400 (#578) --- src/loaders/express.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/loaders/express.ts b/src/loaders/express.ts index df4c079f..add31340 100644 --- a/src/loaders/express.ts +++ b/src/loaders/express.ts @@ -42,7 +42,9 @@ export default function init (container: Container): Application { }) if (typeof process.env.SENTRY_DSN !== 'undefined') { - app.use(Sentry.Handlers.errorHandler() as ErrorRequestHandler) + app.use(Sentry.Handlers.errorHandler({ + shouldHandleError: (err: any) => err.status >= 400 + }) as ErrorRequestHandler) } app.use((err: any, _req: Request, res: Response, _next: NextFunction) => {