Skip to content

Commit

Permalink
ref(core): Streamline SentryError class
Browse files Browse the repository at this point in the history
We did some funky stuff in there that does not seem necessary and can even lead to issues.

Fixes #15214.
  • Loading branch information
mydea committed Jan 29, 2025
1 parent d38b938 commit 26ae6b4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
7 changes: 3 additions & 4 deletions packages/core/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -903,11 +903,10 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
if (DEBUG_BUILD) {
// If something's gone wrong, log the error as a warning. If it's just us having used a `SentryError` for
// control flow, log just the message (no stack) as a log-level log.
const sentryError = reason as SentryError;
if (sentryError.logLevel === 'log') {
logger.log(sentryError.message);
if (reason instanceof SentryError && reason.logLevel === 'log') {
logger.log(reason.message);
} else {
logger.warn(sentryError);
logger.warn(reason);
}
}
return undefined;
Expand Down
8 changes: 0 additions & 8 deletions packages/core/src/utils-hoist/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import type { ConsoleLevel } from '../types-hoist';

/** An error emitted by Sentry SDKs and related utilities. */
export class SentryError extends Error {
/** Display name of this error instance. */
public name: string;

public logLevel: ConsoleLevel;

public constructor(
Expand All @@ -13,11 +10,6 @@ export class SentryError extends Error {
) {
super(message);

this.name = new.target.prototype.constructor.name;
// This sets the prototype to be `Error`, not `SentryError`. It's unclear why we do this, but commenting this line
// out causes various (seemingly totally unrelated) playwright tests consistently time out. FYI, this makes
// instances of `SentryError` fail `obj instanceof SentryError` checks.
Object.setPrototypeOf(this, new.target.prototype);
this.logLevel = logLevel;
}
}

0 comments on commit 26ae6b4

Please sign in to comment.