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
4 changes: 4 additions & 0 deletions src/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2811,6 +2811,10 @@ bool v8__Promise__HasHandler(const v8::Promise& self) {
return ptr_to_local(&self)->HasHandler();
}

void v8__Promise__MarkAsHandled(const v8::Promise& self) {
ptr_to_local(&self)->MarkAsHandled();
}

const v8::Value* v8__Promise__Result(const v8::Promise& self) {
return local_to_ptr(ptr_to_local(&self)->Result());
}
Expand Down
7 changes: 7 additions & 0 deletions src/promise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ unsafe extern "C" {
) -> MaybeBool;
fn v8__Promise__State(this: *const Promise) -> PromiseState;
fn v8__Promise__HasHandler(this: *const Promise) -> bool;
fn v8__Promise__MarkAsHandled(this: *const Promise);
fn v8__Promise__Result(this: *const Promise) -> *const Value;
fn v8__Promise__Catch(
this: *const Promise,
Expand Down Expand Up @@ -79,6 +80,12 @@ impl Promise {
unsafe { v8__Promise__HasHandler(self) }
}

/// Marks this promise as handled to avoid reporting unhandled rejections.
#[inline(always)]
pub fn mark_as_handled(&self) {
unsafe { v8__Promise__MarkAsHandled(self) }
}

/// Returns the content of the [[PromiseResult]] field. The Promise must not
/// be pending.
#[inline(always)]
Expand Down