Skip to content

Commit 9bf840a

Browse files
authored
fix: Ensure originalException has type unknown (#7361)
This used to be typed as `Error | string | null` which is not correct, as technically _anything_ can be thrown. To reflect this existing reality, we have to broaden this type. Note that this _could_ lead to problems for users that currently depend on this type, but any potential issues arising because of this would actually be valid problems that should actually be fixed in the user code (e.g. relying on `error.message` to be present, for example).
1 parent dc696c0 commit 9bf840a

File tree

4 files changed

+4
-6
lines changed

4 files changed

+4
-6
lines changed

packages/core/src/baseclient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
560560
data: {
561561
__sentry__: true,
562562
},
563-
originalException: reason as Error,
563+
originalException: reason,
564564
});
565565
throw new SentryError(
566566
`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${reason}`,

packages/core/src/hub.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ export class Hub implements HubInterface {
183183
/**
184184
* @inheritDoc
185185
*/
186-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
187-
public captureException(exception: any, hint?: EventHint): string {
186+
public captureException(exception: unknown, hint?: EventHint): string {
188187
const eventId = (this._lastEventId = hint && hint.event_id ? hint.event_id : uuid4());
189188
const syntheticException = new Error('Sentry syntheticException');
190189
this._withClient((client, scope) => {

packages/node/src/integrations/onunhandledrejection.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ export class OnUnhandledRejection implements Integration {
4444
* @param reason string
4545
* @param promise promise
4646
*/
47-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
48-
public sendUnhandledPromise(reason: any, promise: any): void {
47+
public sendUnhandledPromise(reason: unknown, promise: unknown): void {
4948
const hub = getCurrentHub();
5049
if (hub.getIntegration(OnUnhandledRejection)) {
5150
hub.withScope((scope: Scope) => {

packages/types/src/event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export interface EventHint {
7575
event_id?: string;
7676
captureContext?: CaptureContext;
7777
syntheticException?: Error | null;
78-
originalException?: Error | string | null;
78+
originalException?: unknown;
7979
attachments?: Attachment[];
8080
data?: any;
8181
integrations?: string[];

0 commit comments

Comments
 (0)