mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 23:10:02 -04:00
fix error preparestacktrace can get overwritten
This commit is contained in:
parent
592e8d183f
commit
c412959a5f
1 changed files with 11 additions and 2 deletions
|
@ -4,16 +4,25 @@ import { ScramjetClient } from "../client";
|
||||||
export const enabled = () => self.$scramjet.config.flags.cleanerrors;
|
export const enabled = () => self.$scramjet.config.flags.cleanerrors;
|
||||||
export default function (client: ScramjetClient, self: Self) {
|
export default function (client: ScramjetClient, self: Self) {
|
||||||
// v8 only. all we need to do is clean the scramjet urls from stack traces
|
// v8 only. all we need to do is clean the scramjet urls from stack traces
|
||||||
Error.prepareStackTrace = (error, stack) => {
|
const closure = (error, stack) => {
|
||||||
let newstack = error.stack;
|
let newstack = error.stack;
|
||||||
|
|
||||||
for (let i = 0; i < stack.length; i++) {
|
for (let i = 0; i < stack.length; i++) {
|
||||||
const url = stack[i].getFileName();
|
const url = stack[i].getFileName();
|
||||||
try {
|
try {
|
||||||
newstack = newstack.replaceAll(url, decodeUrl(url));
|
newstack = newstack.replaceAll(url, decodeUrl(url));
|
||||||
} catch {}
|
} catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
return newstack;
|
return newstack;
|
||||||
};
|
};
|
||||||
|
client.Trap("Error.prepareStackTrace", {
|
||||||
|
get(ctx) {
|
||||||
|
// this is a funny js quirk. the getter is ran every time you type something in console
|
||||||
|
return closure;
|
||||||
|
},
|
||||||
|
set(value) {
|
||||||
|
// just ignore it if a site tries setting their own. not much we can really do
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue