From b47f19ac60da24420a0bc81ffffc172fe13a158a Mon Sep 17 00:00:00 2001 From: velzie Date: Sun, 1 Sep 2024 19:52:39 -0400 Subject: [PATCH] error.stack --- src/client/shared/error.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/client/shared/error.ts diff --git a/src/client/shared/error.ts b/src/client/shared/error.ts new file mode 100644 index 0000000..5446915 --- /dev/null +++ b/src/client/shared/error.ts @@ -0,0 +1,18 @@ +import { decodeUrl } from "../../shared"; +import { ScramjetClient } from "../client"; + +export default function (client: ScramjetClient, self: Self) { + // v8 only. all we need to do is clean the scramjet urls from stack traces + Error.prepareStackTrace = (error, stack) => { + let newstack = error.stack; + + for (let i = 0; i < stack.length; i++) { + const url = stack[i].getFileName(); + try { + newstack = newstack.replaceAll(url, decodeUrl(url)); + } catch {} + } + + return newstack; + }; +}