mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
[internal] Get source URLs in C++
This commit is contained in:
@@ -666,9 +666,6 @@ pub const VirtualMachine = struct {
|
||||
flush_list: std.ArrayList(string),
|
||||
entry_point: ServerEntryPoint = undefined,
|
||||
|
||||
last_syntax_error_filename_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined,
|
||||
last_syntax_error_filename: string = "",
|
||||
|
||||
arena: *std.heap.ArenaAllocator = undefined,
|
||||
has_loaded: bool = false,
|
||||
|
||||
@@ -687,15 +684,6 @@ pub const VirtualMachine = struct {
|
||||
pub threadlocal var vm_loaded = false;
|
||||
pub threadlocal var vm: *VirtualMachine = undefined;
|
||||
|
||||
pub fn getSyntaxErrorFilename(this: *VirtualMachine) ?string {
|
||||
if (this.last_syntax_error_filename.len > 0) {
|
||||
const filename = this.last_syntax_error_filename;
|
||||
this.last_syntax_error_filename = "";
|
||||
return filename;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
pub fn enableMacroMode(this: *VirtualMachine) void {
|
||||
this.bundler.options.platform = .bun_macro;
|
||||
this.macro_mode = true;
|
||||
@@ -1180,12 +1168,6 @@ pub const VirtualMachine = struct {
|
||||
return slice;
|
||||
}
|
||||
|
||||
pub fn setSyntaxErrorFilePath(global: *JSGlobalObject, loader: *JSModuleLoader, key: ZigString) void {
|
||||
var slice = key.slice();
|
||||
std.mem.copy(u8, &vm.last_syntax_error_filename_buf, slice);
|
||||
vm.last_syntax_error_filename = vm.last_syntax_error_filename_buf[0..slice.len];
|
||||
}
|
||||
|
||||
// This double prints
|
||||
pub fn promiseRejectionTracker(global: *JSGlobalObject, promise: *JSPromise, rejection: JSPromiseRejectionOperation) callconv(.C) JSValue {
|
||||
// VirtualMachine.vm.defaultErrorHandler(promise.result(global.vm()), null);
|
||||
@@ -1729,33 +1711,6 @@ pub const VirtualMachine = struct {
|
||||
}
|
||||
|
||||
try printStackTrace(@TypeOf(writer), writer, exception.stack, allow_ansi_color);
|
||||
|
||||
// SyntaxError in JavaScriptCore does not include a filename
|
||||
// This can make debugging syntax errors difficult
|
||||
if (this.getSyntaxErrorFilename()) |filename| {
|
||||
const frame = ZigStackFrame{
|
||||
.function_name = ZigString.Empty,
|
||||
.source_url = ZigString.init(filename),
|
||||
.position = ZigStackFramePosition.Invalid,
|
||||
.code_type = ZigStackFrameCode.Module,
|
||||
};
|
||||
try writer.print(
|
||||
comptime Output.prettyFmt(
|
||||
"<r> <d>at <r>{any} <d>(<r>{any}<d>)<r>\n",
|
||||
allow_ansi_color,
|
||||
),
|
||||
.{
|
||||
frame.nameFormatter(
|
||||
allow_ansi_color,
|
||||
),
|
||||
frame.sourceURLFormatter(
|
||||
vm.bundler.fs.top_level_dir,
|
||||
&vm.bundler.options.origin,
|
||||
allow_ansi_color,
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user