diff --git a/src/engines/v8/v8.zig b/src/engines/v8/v8.zig index 04538c9..7696544 100644 --- a/src/engines/v8/v8.zig +++ b/src/engines/v8/v8.zig @@ -331,6 +331,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 857e7e6..1733959 100644 --- a/src/interfaces.zig +++ b/src/interfaces.zig @@ -80,6 +80,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,