diff --git a/packages/minimal/src/index.ts b/packages/minimal/src/index.ts index 7f5c6fc61dd3..00a1cdd91d44 100644 --- a/packages/minimal/src/index.ts +++ b/packages/minimal/src/index.ts @@ -36,12 +36,8 @@ function callOnHub(method: string, ...args: any[]): T { */ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types export function captureException(exception: any, captureContext?: CaptureContext): string { - let syntheticException: Error; - try { - throw new Error('Sentry syntheticException'); - } catch (exception) { - syntheticException = exception as Error; - } + const syntheticException = new Error('Sentry syntheticException'); + return callOnHub('captureException', exception, { captureContext, originalException: exception, @@ -57,12 +53,7 @@ export function captureException(exception: any, captureContext?: CaptureContext * @returns The generated eventId. */ export function captureMessage(message: string, captureContext?: CaptureContext | Severity): string { - let syntheticException: Error; - try { - throw new Error(message); - } catch (exception) { - syntheticException = exception as Error; - } + const syntheticException = new Error(message); // This is necessary to provide explicit scopes upgrade, without changing the original // arity of the `captureMessage(message, level)` method.