rid nearly all use of ExceptionRef in zig (#15100)

Co-authored-by: nektro <nektro@users.noreply.github.com>
This commit is contained in:
Meghan Denny
2024-11-13 15:23:52 -08:00
committed by GitHub
parent ec91e91fda
commit f8979b05b1
26 changed files with 811 additions and 1932 deletions

View File

@@ -35,32 +35,20 @@ fn callSync(comptime FunctionEnum: NodeFSFunctionEnum) NodeFSFunction {
globalObject: *JSC.JSGlobalObject,
callframe: *JSC.CallFrame,
) JSC.JSValue {
var exceptionref: JSC.C.JSValueRef = null;
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, &exceptionref) orelse {
// we might've already thrown
if (exceptionref != null)
globalObject.throwValue(JSC.JSValue.c(exceptionref));
return .zero;
})
(Arguments.fromJS(globalObject, &slice) catch return .zero)
else
Arguments{};
defer {
if (comptime Arguments != void and @hasDecl(Arguments, "deinit")) args.deinit();
}
const exception1 = JSC.JSValue.c(exceptionref);
if (exception1 != .zero) {
globalObject.throwValue(exception1);
return .zero;
} else if (globalObject.hasException()) {
if (globalObject.hasException()) {
return .zero;
}
var result = Function(
@@ -96,25 +84,15 @@ fn call(comptime FunctionEnum: NodeFSFunctionEnum) NodeFSFunction {
var slice = ArgumentsSlice.init(globalObject.bunVM(), arguments.slice());
slice.will_be_async = true;
var exceptionref: JSC.C.JSValueRef = null;
const args = if (comptime Arguments != void)
(Arguments.fromJS(globalObject, &slice, &exceptionref) orelse {
// we might've already thrown
if (exceptionref != null)
globalObject.throwValue(JSC.JSValue.c(exceptionref));
(Arguments.fromJS(globalObject, &slice) catch {
slice.deinit();
return .zero;
})
else
Arguments{};
const exception1 = JSC.JSValue.c(exceptionref);
if (exception1 != .zero) {
globalObject.throwValue(exception1);
slice.deinit();
return .zero;
} else if (globalObject.hasException()) {
if (globalObject.hasException()) {
slice.deinit();
return .zero;
}