From 55780eee4be2933ae3c620fca86123ac67f17579 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Thu, 5 Dec 2024 12:52:44 +0100 Subject: [PATCH 1/4] Clarify NestJS error filters --- .../getting-started-use/javascript.nestjs.mdx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform-includes/getting-started-use/javascript.nestjs.mdx b/platform-includes/getting-started-use/javascript.nestjs.mdx index ba5c937d25881b..cb9faf4ad67645 100644 --- a/platform-includes/getting-started-use/javascript.nestjs.mdx +++ b/platform-includes/getting-started-use/javascript.nestjs.mdx @@ -49,7 +49,6 @@ export class YourCatchAllExceptionFilter implements ExceptionFilter { } ``` - {/* TODO(v9): Remove this note */} _Note that `@SentryExceptionCaptured()` was called `@WithSentry` in SDK versions `8.38.0` and prior._ @@ -73,12 +72,13 @@ import { SentryGlobalFilter } from "@sentry/nestjs/setup"; }) export class AppModule {} ``` + {/* TODO(v9): Remove this note. */} **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`. In SDK versions `8.39.0` and above, the `SentryGlobalGenericFilter` is deprecated because the `SentryGlobalFilter` will handle GraphQL contexts automatically. -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()`: +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()`: ```javascript {9} import { ArgumentsHost, BadRequestException, Catch } from '@nestjs/common'; @@ -94,3 +94,6 @@ export class ExampleExceptionFilter extends BaseExceptionFilter { } } ``` + +By default, only unhandled exceptions that are not caught by an error filter are reported to Sentry. +Errors that are a `HttpException` also are not captured by default because they mostly act as control flow vehicles. From 798c17012b33639c1fcb9f797ccccec2227f9696 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Thu, 5 Dec 2024 12:54:43 +0100 Subject: [PATCH 2/4] meh --- platform-includes/getting-started-use/javascript.nestjs.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform-includes/getting-started-use/javascript.nestjs.mdx b/platform-includes/getting-started-use/javascript.nestjs.mdx index cb9faf4ad67645..27e5bd3872e4c1 100644 --- a/platform-includes/getting-started-use/javascript.nestjs.mdx +++ b/platform-includes/getting-started-use/javascript.nestjs.mdx @@ -96,4 +96,4 @@ export class ExampleExceptionFilter extends BaseExceptionFilter { ``` By default, only unhandled exceptions that are not caught by an error filter are reported to Sentry. -Errors that are a `HttpException` also are not captured by default because they mostly act as control flow vehicles. +`HttpException`s also are not captured by default because they mostly act as control flow vehicles. From 3d987f8de546f36cffbb867935f2bf710052c7a0 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Thu, 5 Dec 2024 13:01:31 +0100 Subject: [PATCH 3/4] Update platform-includes/getting-started-use/javascript.nestjs.mdx Co-authored-by: Lukas Stracke --- platform-includes/getting-started-use/javascript.nestjs.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform-includes/getting-started-use/javascript.nestjs.mdx b/platform-includes/getting-started-use/javascript.nestjs.mdx index 27e5bd3872e4c1..87602aa5c45acf 100644 --- a/platform-includes/getting-started-use/javascript.nestjs.mdx +++ b/platform-includes/getting-started-use/javascript.nestjs.mdx @@ -96,4 +96,4 @@ export class ExampleExceptionFilter extends BaseExceptionFilter { ``` By default, only unhandled exceptions that are not caught by an error filter are reported to Sentry. -`HttpException`s also are not captured by default because they mostly act as control flow vehicles. +`HttpException`s (including [derivatives](https://docs.nestjs.com/exception-filters#built-in-http-exceptions)) are also not captured by default because they mostly act as control flow vehicles. From 2bcc259703f74a28d4b6e5bb5617293914fd4194 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Thu, 5 Dec 2024 13:15:17 +0100 Subject: [PATCH 4/4] reorder --- platform-includes/getting-started-use/javascript.nestjs.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platform-includes/getting-started-use/javascript.nestjs.mdx b/platform-includes/getting-started-use/javascript.nestjs.mdx index 87602aa5c45acf..dc5fe5d560f3d1 100644 --- a/platform-includes/getting-started-use/javascript.nestjs.mdx +++ b/platform-includes/getting-started-use/javascript.nestjs.mdx @@ -49,6 +49,9 @@ export class YourCatchAllExceptionFilter implements ExceptionFilter { } ``` +By default, only unhandled exceptions that are not caught by an error filter are reported to Sentry. +`HttpException`s (including [derivatives](https://docs.nestjs.com/exception-filters#built-in-http-exceptions)) are also not captured by default because they mostly act as control flow vehicles. + {/* TODO(v9): Remove this note */} _Note that `@SentryExceptionCaptured()` was called `@WithSentry` in SDK versions `8.38.0` and prior._ @@ -94,6 +97,3 @@ export class ExampleExceptionFilter extends BaseExceptionFilter { } } ``` - -By default, only unhandled exceptions that are not caught by an error filter are reported to Sentry. -`HttpException`s (including [derivatives](https://docs.nestjs.com/exception-filters#built-in-http-exceptions)) are also not captured by default because they mostly act as control flow vehicles.