You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platforms/javascript/guides/angular/features/error-handler.mdx
+7-10Lines changed: 7 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -3,14 +3,11 @@ title: Angular Error Handler
3
3
description: "Learn about Sentry's Angular SDK Error Handler and how to configure it."
4
4
---
5
5
6
-
Sentry's Angular SDK provides a custom Angular `ErrorHandler` that automatically extracts and captures errors in your Angular application. The main benefit is that Angular often wraps errors in its own error classes, making
7
-
it hard for Sentry to extract the important data correctly without a custom error handler.
8
-
9
-
On this page, you'll learn how to work with the the SDKs `ErrorHandler` if you need to customize it further.
6
+
Angular often wraps errors in its own error classes, making it hard for Sentry to extract the important data correctly without a custom error handler, which is where Sentry's Angular SDK `ErrorHandler` can help. On this page, you'll learn how to customize the SDK's `ErrorHandler` to work for your use case.
10
7
11
8
## Using the Sentry `ErrorHandler`
12
9
13
-
Simply register the Sentry `ErrorHandler` in your Angular application's providers. We recommend to do this in your main `app.config.ts` or `app.module.ts` file to ensure that the `ErrorHandler` is available everywhere in your application.
10
+
To get started, register the Sentry `ErrorHandler` in your Angular application's providers. We recommend to do this in your main `app.config.ts` or `app.module.ts` file to ensure that the `ErrorHandler` is available everywhere in your application.
Optionally, you can configure the behavior of the `ErrorHandler` by passing an object to the `createErrorHandler` function. The following options are available:
48
+
As an alternative, you can configure the behavior of the `ErrorHandler` by passing an object to the `createErrorHandler` function. The following options are available:
52
49
53
50
#### `logErrors`
54
51
55
52
_Type: `boolean` Default: `true`_
56
53
57
-
Log errors to the console. This is `true` by default, to ensure consistency with Angular's default behavior.
54
+
Lets you log errors to the console. This is `true` by default to ensure consistency with Angular's default behavior.
58
55
59
56
#### `extractor`
60
57
61
58
_Type: `function` Default: `undefined`_
62
59
63
-
A function that extracts the raw, incoming error object. By default, the SDK uses its own extraction logic but you can override it by providing your own function.
60
+
Lets you extract the raw, incoming error object. The SDK uses its own extraction logic by default, but you can override it by providing your own function.
64
61
65
62
## Multiple Error Handlers
66
63
67
-
Angular doesn't allow providing multiple `ErrorHandler` instances in the same Angular application in `app.config.ts` or `app.module.ts`.
68
-
Therefore, if you're using your own error handler or you want to add additional logic to Sentry's `ErrorHandler`, extend Sentry's `ErrorHandler`:
64
+
Angular doesn't let you provide multiple `ErrorHandler` instances in the same Angular application in `app.config.ts` or `app.module.ts`.
65
+
Therefore, if you're using your own error handler or you want to add additional logic to Sentry's `ErrorHandler`, you have to extend Sentry's `ErrorHandler` like in the example below:
Copy file name to clipboardExpand all lines: platform-includes/getting-started-config/javascript.angular.mdx
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -71,7 +71,7 @@ import * as Sentry from "@sentry/angular";
71
71
exportclassAppModule {}
72
72
```
73
73
74
-
The `Sentry.createErrorHandler` function initializes a Sentry-specific `ErrorHandler` that automatically sends errors caught by Angular to Sentry. Cou can further [configure](./features/error-handler) Sentry's `ErrorHandler` behavior.
74
+
The `Sentry.createErrorHandler` function initializes a Sentry-specific `ErrorHandler` that automatically sends errors caught by Angular to Sentry. Learn how to further configure Sentry's `ErrorHandler` behavior[here](./features/error-handler).
75
75
76
76
<OnboardingOptionoptionId="performance">
77
77
The `Sentry.TraceService` listens to the Angular router for tracing. To inject `TraceService`, register the `APP_INITIALIZER` provider as shown above. Alternatively, you can also require the `TraceService` from inside your `AppModule` constructor:
0 commit comments