-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
error.ts
20 lines (16 loc) · 808 Bytes
/
error.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import type { ConsoleLevel } from './logger';
/** 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(public message: string, logLevel: ConsoleLevel = 'warn') {
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;
}
}