diff --git a/src/engines/v8/v8.zig b/src/engines/v8/v8.zig index bd6d22e..2d1c55d 100644 --- a/src/engines/v8/v8.zig +++ b/src/engines/v8/v8.zig @@ -345,6 +345,21 @@ pub const Env = struct { }; } + pub fn waitTryCatch( + self: Env, + alloc: std.mem.Allocator, + ) anyerror!JSResult { + + // JS try cache + var try_catch: v8.TryCatch = undefined; + try_catch.init(self.isolate); + defer try_catch.deinit(); + + var res = JSResult{}; + try self.wait(alloc, try_catch, &res); + return res; + } + // run a JS script and wait for all callbacks // try_catch + exec + wait pub fn run( diff --git a/src/interfaces.zig b/src/interfaces.zig index 36c8f1c..683b449 100644 --- a/src/interfaces.zig +++ b/src/interfaces.zig @@ -94,6 +94,12 @@ pub fn Env( // TODO: check exec, wait who have v8 specific params + // waitTryCatch + assertDecl(T, "waitTryCatch", fn ( + self: T, + alloc: std.mem.Allocator, + ) anyerror!JSResult_T); + // execTryCatch() executes script in JS assertDecl(T, "execTryCatch", fn ( self: T,