Skip to content

Commit 4dd5b52

Browse files
fix: all errors getting sent to sentry
1 parent 35788ab commit 4dd5b52

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,15 @@ Sentry.init({
3333
});
3434

3535
instance.setErrorHandler(async (error, request, reply) => {
36+
if (error.statusCode && error.statusCode < 500) {
37+
return reply.send(error);
38+
} // http-errors are thrown for 4xx errors, which should not be sent to sentry
3639
Sentry.captureException(error);
3740
instance.log.error(error);
41+
if (error.statusCode) {
42+
return reply.send(error);
43+
} // If any errors were http-errors pretty much, they shouldn't be overwritten
44+
3845
return reply.status(500).send({
3946
statusCode: 500,
4047
error: "Internal Server Error",

0 commit comments

Comments
 (0)