zig: make throw use JSError (#15444)

This commit is contained in:
Meghan Denny
2024-12-02 14:19:18 -08:00
committed by GitHub
parent 56ad4cc4a6
commit 2d441d868b
58 changed files with 872 additions and 1632 deletions

View File

@@ -1099,15 +1099,13 @@ pub const TestingAPIs = struct {
var arguments = JSC.Node.ArgumentsSlice.init(globalThis.bunVM(), arguments_.slice());
const old_folder_jsval = arguments.nextEat() orelse {
globalThis.throw("expected 2 strings", .{});
return .zero;
return globalThis.throw("expected 2 strings", .{});
};
const old_folder_bunstr = old_folder_jsval.toBunString(globalThis);
defer old_folder_bunstr.deref();
const new_folder_jsval = arguments.nextEat() orelse {
globalThis.throw("expected 2 strings", .{});
return .zero;
return globalThis.throw("expected 2 strings", .{});
};
const new_folder_bunstr = new_folder_jsval.toBunString(globalThis);
defer new_folder_bunstr.deref();
@@ -1127,8 +1125,7 @@ pub const TestingAPIs = struct {
},
.err => |e| {
defer e.deinit();
globalThis.throw("failed to make diff: {s}", .{e.items});
return .zero;
return globalThis.throw("failed to make diff: {s}", .{e.items});
},
};
}
@@ -1153,8 +1150,7 @@ pub const TestingAPIs = struct {
defer args.deinit();
if (args.patchfile.apply(bun.default_allocator, args.dirfd)) |err| {
globalThis.throwValue(err.toErrorInstance(globalThis));
return .zero;
return globalThis.throwValue(err.toErrorInstance(globalThis));
}
return .true;
@@ -1165,8 +1161,7 @@ pub const TestingAPIs = struct {
var arguments = JSC.Node.ArgumentsSlice.init(globalThis.bunVM(), arguments_.slice());
const patchfile_src_js = arguments.nextEat() orelse {
globalThis.throw("TestingAPIs.parse: expected at least 1 argument, got 0", .{});
return .zero;
return globalThis.throw("TestingAPIs.parse: expected at least 1 argument, got 0", .{});
};
const patchfile_src_bunstr = patchfile_src_js.toBunString(globalThis);
const patchfile_src = patchfile_src_bunstr.toUTF8(bun.default_allocator);
@@ -1190,7 +1185,7 @@ pub const TestingAPIs = struct {
var arguments = JSC.Node.ArgumentsSlice.init(globalThis.bunVM(), arguments_.slice());
const patchfile_js = arguments.nextEat() orelse {
globalThis.throw("apply: expected at least 1 argument, got 0", .{});
globalThis.throw("apply: expected at least 1 argument, got 0", .{}) catch {};
return .{ .err = .undefined };
};
@@ -1202,7 +1197,7 @@ pub const TestingAPIs = struct {
break :brk switch (bun.sys.open(path, bun.O.DIRECTORY | bun.O.RDONLY, 0)) {
.err => |e| {
globalThis.throwValue(e.withPath(path).toJSC(globalThis));
globalThis.throwValue(e.withPath(path).toJSC(globalThis)) catch {};
return .{ .err = .undefined };
},
.result => |fd| fd,