mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 12:51:54 +00:00
fix: add a better error message for fetch when it fails with an unknown code (#9663)
* add a better error message for fetch when it fails with an unknown code * Update src/bun.js/webcore/response.zig Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> * [autofix.ci] apply automated fixes * fix compilation --------- Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
36
src/bun.js/bindings/GeneratedJS2Native.zig
Normal file
36
src/bun.js/bindings/GeneratedJS2Native.zig
Normal file
@@ -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;
|
||||
}
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user