mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 21:01:52 +00:00
Error.captureStackTrace implementation (#1476)
* capture stack trace formatting, tests * fix callsite methods, stack formatting or undefined * isNative, tests for callsite methods * Update src/bun.js/bindings/ZigGlobalObject.cpp * Update src/bun.js/bindings/ZigGlobalObject.cpp * template and macros for visitchildren * static strings, handle infinity and clamp stacktracelimit Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
This commit is contained in:
@@ -1551,6 +1551,25 @@ pub const VirtualMachine = struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub export fn Bun__remapStackFramePositions(globalObject: *JSC.JSGlobalObject, frames: [*]JSC.ZigStackFrame, frames_count: usize) void {
|
||||
globalObject.bunVM().remapStackFramePositions(frames, frames_count);
|
||||
}
|
||||
|
||||
pub fn remapStackFramePositions(this: *VirtualMachine, frames: [*]JSC.ZigStackFrame, frames_count: usize) void {
|
||||
var i: usize = 0;
|
||||
while (i < frames_count) : (i += 1) {
|
||||
if (frames[i].position.isInvalid()) continue;
|
||||
if (this.source_mappings.resolveMapping(
|
||||
frames[i].source_url.slice(),
|
||||
@maximum(frames[i].position.line, 0),
|
||||
@maximum(frames[i].position.column_start, 0),
|
||||
)) |mapping| {
|
||||
frames[i].position.line = mapping.original.lines;
|
||||
frames[i].position.column_start = mapping.original.columns;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remapZigException(
|
||||
this: *VirtualMachine,
|
||||
exception: *ZigException,
|
||||
@@ -1831,6 +1850,11 @@ pub const VirtualMachine = struct {
|
||||
try writer.print(comptime Output.prettyFmt("<r><red>error<r>\n", allow_ansi_color), .{});
|
||||
}
|
||||
}
|
||||
|
||||
comptime {
|
||||
if (!JSC.is_bindgen)
|
||||
_ = Bun__remapStackFramePositions;
|
||||
}
|
||||
};
|
||||
|
||||
const GetterFn = fn (
|
||||
|
||||
Reference in New Issue
Block a user