Skip to content

Commit 55780ee

Browse files
author
Luca Forstner
committed
Clarify NestJS error filters
1 parent 290f357 commit 55780ee

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

platform-includes/getting-started-use/javascript.nestjs.mdx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export class YourCatchAllExceptionFilter implements ExceptionFilter {
4949
}
5050
```
5151

52-
5352
{/* TODO(v9): Remove this note */}
5453
_Note that `@SentryExceptionCaptured()` was called `@WithSentry` in SDK versions `8.38.0` and prior._
5554

@@ -73,12 +72,13 @@ import { SentryGlobalFilter } from "@sentry/nestjs/setup";
7372
})
7473
export class AppModule {}
7574
```
75+
7676
{/* TODO(v9): Remove this note. */}
7777

7878
**Note:** If you have a NestJS + GraphQL application and you are using the `@sentry/nestjs` SDK version `8.38.0` or earlier, replace the `SentryGlobalFilter` with the `SentryGlobalGenericFilter`.
7979
In SDK versions `8.39.0` and above, the `SentryGlobalGenericFilter` is deprecated because the `SentryGlobalFilter` will handle GraphQL contexts automatically.
8080

81-
By default, exceptions with status code 4xx are not sent to Sentry. If you still want to capture these exceptions, you can do so manually with `Sentry.captureException()`:
81+
If you have error filters for specific types of exceptions (for example `@Catch(HttpException)`, or any other `@Catch(...)` with arguments) and you want to capture errors caught by these filters, capture the errors in the `catch()` handler with `Sentry.captureException()`:
8282

8383
```javascript {9}
8484
import { ArgumentsHost, BadRequestException, Catch } from '@nestjs/common';
@@ -94,3 +94,6 @@ export class ExampleExceptionFilter extends BaseExceptionFilter {
9494
}
9595
}
9696
```
97+
98+
By default, only unhandled exceptions that are not caught by an error filter are reported to Sentry.
99+
Errors that are a `HttpException` also are not captured by default because they mostly act as control flow vehicles.

0 commit comments

Comments
 (0)