Skip to content

Commit fc6203e

Browse files
committed
add Promise::MarkAsHandled
1 parent 19b5ecf commit fc6203e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/binding.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,6 +2811,10 @@ bool v8__Promise__HasHandler(const v8::Promise& self) {
28112811
return ptr_to_local(&self)->HasHandler();
28122812
}
28132813

2814+
void v8__Promise__MarkAsHandled(const v8::Promise& self) {
2815+
ptr_to_local(&self)->MarkAsHandled();
2816+
}
2817+
28142818
const v8::Value* v8__Promise__Result(const v8::Promise& self) {
28152819
return local_to_ptr(ptr_to_local(&self)->Result());
28162820
}

src/promise.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ unsafe extern "C" {
2828
) -> MaybeBool;
2929
fn v8__Promise__State(this: *const Promise) -> PromiseState;
3030
fn v8__Promise__HasHandler(this: *const Promise) -> bool;
31+
fn v8__Promise__MarkAsHandled(this: *const Promise);
3132
fn v8__Promise__Result(this: *const Promise) -> *const Value;
3233
fn v8__Promise__Catch(
3334
this: *const Promise,
@@ -79,6 +80,12 @@ impl Promise {
7980
unsafe { v8__Promise__HasHandler(self) }
8081
}
8182

83+
/// Marks this promise as handled to avoid reporting unhandled rejections.
84+
#[inline(always)]
85+
pub fn mark_as_handled(&self) {
86+
unsafe { v8__Promise__MarkAsHandled(self) }
87+
}
88+
8289
/// Returns the content of the [[PromiseResult]] field. The Promise must not
8390
/// be pending.
8491
#[inline(always)]

0 commit comments

Comments
 (0)