Skip to content

Commit 215d57d

Browse files
committed
improve synthetic exception in hub
1 parent fe8e51b commit 215d57d

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

packages/hub/src/hub.ts

+2-17
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,9 @@ export class Hub implements HubInterface {
185185
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
186186
public captureException(exception: any, hint?: EventHint): string {
187187
const eventId = (this._lastEventId = hint && hint.event_id ? hint.event_id : uuid4());
188-
189-
let syntheticException: Error;
190-
try {
191-
throw new Error('Sentry syntheticException');
192-
} catch (exception) {
193-
syntheticException = exception as Error;
194-
}
195188
this._invokeClient('captureException', exception, {
196189
originalException: exception,
197-
syntheticException,
190+
syntheticException: new Error('Sentry syntheticException'),
198191
...hint,
199192
event_id: eventId,
200193
});
@@ -211,17 +204,9 @@ export class Hub implements HubInterface {
211204
hint?: EventHint,
212205
): string {
213206
const eventId = (this._lastEventId = hint && hint.event_id ? hint.event_id : uuid4());
214-
215-
let syntheticException: Error;
216-
try {
217-
throw new Error('Sentry syntheticException');
218-
} catch (exception) {
219-
syntheticException = exception as Error;
220-
}
221-
222207
this._invokeClient('captureMessage', message, level, {
223208
originalException: message,
224-
syntheticException,
209+
syntheticException: new Error(message),
225210
...hint,
226211
event_id: eventId,
227212
});

packages/hub/test/exports.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { getCurrentHub, getHubFromCarrier, Scope } from '../src';
2-
32
import {
43
captureEvent,
54
captureException,

0 commit comments

Comments
 (0)