Skip to content

Commit ac65b8d

Browse files
authored
Suggest using SentryExceptionCaptured instead of WithSentry (#11833)
1 parent 1715fe4 commit ac65b8d

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

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

+21-20
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
```javascript {filename: main.ts}
22
// Import this first!
3-
import './instrument';
3+
import "./instrument";
44

55
// Now import other modules
6-
import { NestFactory } from '@nestjs/core';
7-
import { AppModule } from './app.module';
6+
import { NestFactory } from "@nestjs/core";
7+
import { AppModule } from "./app.module";
88

99
async function bootstrap() {
1010
const app = await NestFactory.create(AppModule);
@@ -17,48 +17,49 @@ bootstrap();
1717
Afterwards, add the `SentryModule` as a root module to your main module:
1818

1919
```javascript {filename: app.module.ts} {2, 8}
20-
import { Module } from '@nestjs/common';
21-
import { SentryModule } from '@sentry/nestjs/setup';
22-
import { AppController } from './app.controller';
23-
import { AppService } from './app.service';
20+
import { Module } from "@nestjs/common";
21+
import { SentryModule } from "@sentry/nestjs/setup";
22+
import { AppController } from "./app.controller";
23+
import { AppService } from "./app.service";
2424

2525
@Module({
2626
imports: [
27-
SentryModule.forRoot(),
28-
// ...other modules
27+
SentryModule.forRoot(),
28+
// ...other modules
2929
],
3030
controllers: [AppController],
3131
providers: [AppService],
3232
})
3333
export class AppModule {}
3434
```
3535

36-
In case you are using a global catch-all exception filter (which is either a filter registered with
37-
`app.useGlobalFilters()` or a filter registered in your app module providers annotated with a `@Catch()` decorator
38-
without arguments), add a `@WithSentry()` decorator to the `catch()` method of this global error filter. This decorator
39-
will report all unexpected errors that are received by your global error filter to Sentry:
36+
If you're using a global catch-all exception filter (which is either a filter registered with `app.useGlobalFilters()` or a filter registered in your app module providers annotated with a `@Catch()` decorator without arguments), add a `@SentryExceptionCaptured()` decorator to the filter's `catch()` method.
37+
This decorator will report all unexpected errors that are received by your global error filter to Sentry:
4038

4139
```javascript {2, 6}
4240
import { Catch, ExceptionFilter } from '@nestjs/common';
43-
import { WithSentry } from '@sentry/nestjs';
41+
import { SentryExceptionCaptured } from '@sentry/nestjs';
4442

4543
@Catch()
4644
export class YourCatchAllExceptionFilter implements ExceptionFilter {
47-
@WithSentry()
45+
@SentryExceptionCaptured()
4846
catch(exception, host): void {
4947
// your implementation here
5048
}
5149
}
5250
```
5351

54-
In case you do not have a global catch-all exception filter, add the `SentryGlobalFilter` to the providers of your main
55-
module. This filter will report all unhandled errors to Sentry that are not caught by any other error filter.
52+
{/* TODO(v9): Remove this note */}
53+
_Note that `@SentryExceptionCaptured()` was called `@WithSentry` in SDK versions `8.38.0` and prior._
54+
55+
If you don't have a global catch-all exception filter, add the `SentryGlobalFilter` to the providers of your main module.
56+
This filter will report any unhandled errors that aren't caught by other error filters to Sentry.
5657
**Important:** The `SentryGlobalFilter` needs to be registered before any other exception filters.
5758

5859
```javascript {3, 9}
59-
import { Module } from '@nestjs/common';
60-
import { APP_FILTER } from '@nestjs/core';
61-
import { SentryGlobalFilter } from '@sentry/nestjs/setup';
60+
import { Module } from "@nestjs/common";
61+
import { APP_FILTER } from "@nestjs/core";
62+
import { SentryGlobalFilter } from "@sentry/nestjs/setup";
6263

6364
@Module({
6465
providers: [

0 commit comments

Comments
 (0)