Skip to content

Commit bd24469

Browse files
committed
add env.waitTryCatch
1 parent e8b74e1 commit bd24469

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/engines/v8/v8.zig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,21 @@ pub const Env = struct {
331331
};
332332
}
333333

334+
pub fn waitTryCatch(
335+
self: Env,
336+
alloc: std.mem.Allocator,
337+
) anyerror!JSResult {
338+
339+
// JS try cache
340+
var try_catch: v8.TryCatch = undefined;
341+
try_catch.init(self.isolate);
342+
defer try_catch.deinit();
343+
344+
var res = JSResult{};
345+
try self.wait(alloc, try_catch, &res);
346+
return res;
347+
}
348+
334349
// run a JS script and wait for all callbacks
335350
// try_catch + exec + wait
336351
pub fn run(

src/interfaces.zig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ pub fn Env(
8080

8181
// TODO: check exec, wait who have v8 specific params
8282

83+
// waitTryCatch
84+
assertDecl(T, "waitTryCatch", fn (
85+
self: T,
86+
alloc: std.mem.Allocator,
87+
) anyerror!JSResult_T);
88+
8389
// execTryCatch() executes script in JS
8490
assertDecl(T, "execTryCatch", fn (
8591
self: T,

0 commit comments

Comments
 (0)