Skip to content

Commit 755a519

Browse files
committed
Use event processor to pass mechanism.
1 parent 438e74f commit 755a519

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

packages/angular/src/errorhandler.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { HttpErrorResponse } from '@angular/common/http';
22
import { ErrorHandler as AngularErrorHandler, Inject, Injectable } from '@angular/core';
33
import * as Sentry from '@sentry/browser';
4-
import { getCurrentHub } from '@sentry/browser';
4+
import { captureException } from '@sentry/browser';
5+
import { addExceptionMechanism } from '@sentry/utils';
56

67
import { runOutsideAngular } from './zone';
78

@@ -42,7 +43,18 @@ class SentryErrorHandler implements AngularErrorHandler {
4243

4344
// Capture handled exception and send it to Sentry.
4445
const eventId = runOutsideAngular(() =>
45-
getCurrentHub().captureException(extractedError, { data: { mechanism: { type: 'angular', handled: false } } }),
46+
captureException(extractedError, scope => {
47+
scope.addEventProcessor(event => {
48+
addExceptionMechanism(event, {
49+
type: 'angular',
50+
handled: false,
51+
});
52+
53+
return event;
54+
});
55+
56+
return scope;
57+
}),
4658
);
4759

4860
// When in development mode, log the error to console for immediate feedback.

0 commit comments

Comments
 (0)