Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/engines/v8/v8.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 6 additions & 0 deletions src/interfaces.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down