0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

fix(ext/web): Preserve stack traces for DOMExceptions (#11959)

This commit is contained in:
Nayeem Rahman 2021-09-08 22:14:26 +01:00 committed by GitHub
parent b31dad89a6
commit d947629292
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -1,2 +1,3 @@
[WILDCARD]error: Uncaught SyntaxError: foo
[WILDCARD]
at file:///[WILDCARD]/dom_exception_formatting.ts:[WILDCARD]

View file

@ -11,6 +11,8 @@
((window) => {
const {
ArrayPrototypeSlice,
Error,
ErrorPrototype,
ObjectDefineProperty,
ObjectEntries,
@ -94,6 +96,16 @@
context: "Argument 2",
});
this.#code = nameToCodeMapping[this.#name] ?? 0;
// `DOMException` does not have `.stack`, so `Error.prepareStackTrace()`
// is not called on it, meaning our structured stack trace hack doesn't
// apply. This patches it in.
const error = new Error();
error.stack;
ObjectDefineProperty(this, "__callSiteEvals", {
value: ArrayPrototypeSlice(error.__callSiteEvals, 1),
configurable: true,
});
}
get message() {