Skip to content

Commit

Permalink
add env.waitTryCatch
Browse files Browse the repository at this point in the history
  • Loading branch information
krichprollsch committed May 7, 2024
1 parent e8b74e1 commit bd24469
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/engines/v8/v8.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions src/interfaces.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit bd24469

Please sign in to comment.