diff --git a/src/bun.js/bindings/GeneratedJS2Native.zig b/src/bun.js/bindings/GeneratedJS2Native.zig new file mode 100644 index 0000000000..73cb06092d --- /dev/null +++ b/src/bun.js/bindings/GeneratedJS2Native.zig @@ -0,0 +1,36 @@ +//! This file is generated by src/codegen/js2native-generator.ts based on seen calls to the $zig() JS macro +const JSC = @import("root").bun.JSC; +export fn JS2Zig__createBinding_workaround(global: u64) callconv(.C) JSC.JSValue { + return @import("../node/node_fs_binding.zig").createBinding(@ptrFromInt(global)); +} +export fn JS2Zig__createNodeHttp_Binding_workaround(global: u64) callconv(.C) JSC.JSValue { + return @import("../api/bun/h2_frame_parser.zig").createNodeHttp2Binding(@ptrFromInt(global)); +} +export fn JS2Zig__OS_create_workaround(global: u64) callconv(.C) JSC.JSValue { + return @import("../node/node_os.zig").OS.create(@ptrFromInt(global)); +} +export fn JS2Zig__String_jsGetStringWidth(global: *JSC.JSGlobalObject, call_frame: *JSC.CallFrame) callconv(.C) JSC.JSValue { + return @import("../../string.zig").String.jsGetStringWidth(global, call_frame); +} +export fn JS2Zig__parseArgs(global: *JSC.JSGlobalObject, call_frame: *JSC.CallFrame) callconv(.C) JSC.JSValue { + return @import("../node/util/parse_args.zig").parseArgs(global, call_frame); +} +export fn JS2Zig__QuickAndDirtyJavaScriptSyntaxHighlighter_jsFunctionSyntaxHighlight(global: *JSC.JSGlobalObject, call_frame: *JSC.CallFrame) callconv(.C) JSC.JSValue { + return @import("../../fmt.zig").QuickAndDirtyJavaScriptSyntaxHighlighter.jsFunctionSyntaxHighlight(global, call_frame); +} +export fn JS2Zig__TestingAPIs_shellLex(global: *JSC.JSGlobalObject, call_frame: *JSC.CallFrame) callconv(.C) JSC.JSValue { + return @import("../../shell/shell.zig").TestingAPIs.shellLex(global, call_frame); +} +export fn JS2Zig__TestingAPIs_shellParse(global: *JSC.JSGlobalObject, call_frame: *JSC.CallFrame) callconv(.C) JSC.JSValue { + return @import("../../shell/shell.zig").TestingAPIs.shellParse(global, call_frame); +} +comptime { + _ = &JS2Zig__createBinding_workaround; + _ = &JS2Zig__createNodeHttp_Binding_workaround; + _ = &JS2Zig__OS_create_workaround; + _ = &JS2Zig__String_jsGetStringWidth; + _ = &JS2Zig__parseArgs; + _ = &JS2Zig__QuickAndDirtyJavaScriptSyntaxHighlighter_jsFunctionSyntaxHighlight; + _ = &JS2Zig__TestingAPIs_shellLex; + _ = &JS2Zig__TestingAPIs_shellParse; +} \ No newline at end of file diff --git a/src/bun.js/webcore/response.zig b/src/bun.js/webcore/response.zig index e864cd405f..d301b82c53 100644 --- a/src/bun.js/webcore/response.zig +++ b/src/bun.js/webcore/response.zig @@ -1304,7 +1304,11 @@ pub const Fetch = struct { error.STORE_LOOKUP => bun.String.static("Issuer certificate lookup error"), error.NAME_CONSTRAINTS_WITHOUT_SANS => bun.String.static("Issuer has name constraints but leaf has no SANs"), error.UNKKNOW_CERTIFICATE_VERIFICATION_ERROR => bun.String.static("unknown certificate verification error"), - else => bun.String.static("fetch() failed. For more information, pass `verbose: true` in the second argument to fetch()"), + + else => |e| bun.String.createFormat("{s} fetching \"{}\". For more information, pass `verbose: true` in the second argument to fetch()", .{ + @errorName(e), + path, + }) catch bun.outOfMemory(), }, .path = path, }; diff --git a/src/string.zig b/src/string.zig index 77bdc5beeb..dd34b813a7 100644 --- a/src/string.zig +++ b/src/string.zig @@ -397,6 +397,14 @@ pub const String = extern struct { return BunString__fromUTF16(bytes.ptr, bytes.len); } + pub fn createFormat(comptime fmt: []const u8, args: anytype) !String { + var sba = std.heap.stackFallback(16384, bun.default_allocator); + const alloc = sba.get(); + const buf = try std.fmt.allocPrint(alloc, fmt, args); + defer alloc.free(buf); + return createUTF8(buf); + } + pub fn createFromOSPath(os_path: bun.OSPathSlice) String { return switch (@TypeOf(os_path)) { []const u8 => createUTF8(os_path),