allow zig js host functions to return JSError (#15120)

This commit is contained in:
Meghan Denny
2024-11-13 21:11:56 -08:00
committed by GitHub
parent 32ddf343ee
commit fdd8d35845
70 changed files with 827 additions and 876 deletions

View File

@@ -429,10 +429,14 @@ pub export fn Bun__GlobalObject__hasIPC(global: *JSC.JSGlobalObject) bool {
extern fn Bun__Process__queueNextTick1(*JSC.ZigGlobalObject, JSC.JSValue, JSC.JSValue) void;
pub export fn Bun__Process__send(
comptime {
const Bun__Process__send = JSC.toJSHostFunction(Bun__Process__send_);
@export(Bun__Process__send, .{ .name = "Bun__Process__send" });
}
pub fn Bun__Process__send_(
globalObject: *JSGlobalObject,
callFrame: *JSC.CallFrame,
) callconv(JSC.conv) JSValue {
) bun.JSError!JSC.JSValue {
JSC.markBinding(@src());
var message, var handle, var options_, var callback = callFrame.arguments(4).ptr;
@@ -453,7 +457,7 @@ pub export fn Bun__Process__send(
}
const S = struct {
fn impl(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(JSC.conv) JSC.JSValue {
fn impl(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
const arguments_ = callframe.arguments(1).slice();
const ex = arguments_[0];
VirtualMachine.Process__emitErrorEvent(globalThis, ex);
@@ -4543,7 +4547,7 @@ comptime {
@export(string_allocation_limit, .{ .name = "Bun__stringSyntheticAllocationLimit" });
}
pub export fn Bun__setSyntheticAllocationLimitForTesting(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(JSC.conv) JSValue {
pub fn Bun__setSyntheticAllocationLimitForTesting(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSValue {
const args = callframe.arguments(1).slice();
if (args.len < 1) {
globalObject.throwNotEnoughArguments("setSyntheticAllocationLimitForTesting", 1, args.len);