mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 10:59:13 +00:00
fix: add stackTraceLimit to ErrorConstructor interface and removed ErrorWithStackTraceLimit interface (#28539)
Signed-off-by: Jake Champion <me@jakechampion.name>
This commit is contained in:
parent
1eaac23af8
commit
5aeb04f443
2 changed files with 4 additions and 9 deletions
1
cli/tsc/dts/lib.deno.shared_globals.d.ts
vendored
1
cli/tsc/dts/lib.deno.shared_globals.d.ts
vendored
|
@ -907,6 +907,7 @@ declare var CustomEvent: {
|
|||
interface ErrorConstructor {
|
||||
/** See https://v8.dev/docs/stack-trace-api#stack-trace-collection-for-custom-exceptions. */
|
||||
captureStackTrace(error: Object, constructor?: Function): void;
|
||||
stackTraceLimit: number;
|
||||
// TODO(nayeemrmn): Support `Error.prepareStackTrace()`. We currently use this
|
||||
// internally in a way that makes it unavailable for users.
|
||||
}
|
||||
|
|
|
@ -373,10 +373,6 @@ export interface AssertionErrorConstructorOptions {
|
|||
stackStartFunction?: Function;
|
||||
}
|
||||
|
||||
interface ErrorWithStackTraceLimit extends ErrorConstructor {
|
||||
stackTraceLimit: number;
|
||||
}
|
||||
|
||||
export class AssertionError extends Error {
|
||||
[key: string]: unknown;
|
||||
|
||||
|
@ -398,10 +394,8 @@ export class AssertionError extends Error {
|
|||
expected,
|
||||
} = options;
|
||||
|
||||
// TODO(schwarzkopfb): `stackTraceLimit` should be added to `ErrorConstructor` in
|
||||
// cli/dts/lib.deno.shared_globals.d.ts
|
||||
const limit = (Error as ErrorWithStackTraceLimit).stackTraceLimit;
|
||||
(Error as ErrorWithStackTraceLimit).stackTraceLimit = 0;
|
||||
const limit = Error.stackTraceLimit;
|
||||
Error.stackTraceLimit = 0;
|
||||
|
||||
if (message != null) {
|
||||
super(String(message));
|
||||
|
@ -501,7 +495,7 @@ export class AssertionError extends Error {
|
|||
}
|
||||
}
|
||||
|
||||
(Error as ErrorWithStackTraceLimit).stackTraceLimit = limit;
|
||||
Error.stackTraceLimit = limit;
|
||||
|
||||
this.generatedMessage = !message;
|
||||
ObjectDefineProperty(this, "name", {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue