mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 12:51:54 +00:00
allow zig js host functions to return JSError (#15120)
This commit is contained in:
@@ -14,7 +14,7 @@ const NodeFSFunction = fn (
|
||||
this: *JSC.Node.NodeJSFS,
|
||||
globalObject: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue;
|
||||
) bun.JSError!JSC.JSValue;
|
||||
|
||||
const NodeFSFunctionEnum = std.meta.DeclEnum(JSC.Node.NodeFS);
|
||||
|
||||
@@ -34,14 +34,14 @@ fn callSync(comptime FunctionEnum: NodeFSFunctionEnum) NodeFSFunction {
|
||||
this: *JSC.Node.NodeJSFS,
|
||||
globalObject: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) bun.JSError!JSC.JSValue {
|
||||
var arguments = callframe.arguments(8);
|
||||
|
||||
var slice = ArgumentsSlice.init(globalObject.bunVM(), arguments.slice());
|
||||
defer slice.deinit();
|
||||
|
||||
const args = if (comptime Arguments != void)
|
||||
(Arguments.fromJS(globalObject, &slice) catch return .zero)
|
||||
(try Arguments.fromJS(globalObject, &slice))
|
||||
else
|
||||
Arguments{};
|
||||
defer {
|
||||
@@ -79,7 +79,7 @@ fn call(comptime FunctionEnum: NodeFSFunctionEnum) NodeFSFunction {
|
||||
comptime if (function.params.len != 3) @compileError("Expected 3 arguments");
|
||||
const Arguments = comptime function.params[1].type.?;
|
||||
const NodeBindingClosure = struct {
|
||||
pub fn bind(this: *JSC.Node.NodeJSFS, globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JSC.JSValue {
|
||||
pub fn bind(this: *JSC.Node.NodeJSFS, globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
var arguments = callframe.arguments(8);
|
||||
|
||||
var slice = ArgumentsSlice.init(globalObject.bunVM(), arguments.slice());
|
||||
@@ -244,7 +244,7 @@ pub fn createBinding(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
return module.toJS(globalObject);
|
||||
}
|
||||
|
||||
pub fn createMemfdForTesting(globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) JSC.JSValue {
|
||||
pub fn createMemfdForTesting(globalObject: *JSC.JSGlobalObject, callFrame: *JSC.CallFrame) bun.JSError!JSC.JSValue {
|
||||
const arguments = callFrame.arguments(1);
|
||||
|
||||
if (arguments.len < 1) {
|
||||
|
||||
Reference in New Issue
Block a user