From 65273a46312983b4b5f3d77eef60d48cea57b6e1 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Sat, 30 Dec 2023 11:56:36 +0800 Subject: [PATCH] chore(napi): add status to error messages in AsyncWork (#1880) --- crates/napi/src/async_work.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/napi/src/async_work.rs b/crates/napi/src/async_work.rs index acd29b69..8ea5c35a 100644 --- a/crates/napi/src/async_work.rs +++ b/crates/napi/src/async_work.rs @@ -127,12 +127,20 @@ unsafe extern "C" fn complete( { Ok(v) => { let status = unsafe { sys::napi_resolve_deferred(env, deferred, v) }; - debug_assert!(status == sys::Status::napi_ok, "Resolve promise failed"); + debug_assert!( + status == sys::Status::napi_ok, + "Resolve promise failed, status: {:?}", + crate::Status::from(status) + ); } Err(e) => { let status = unsafe { sys::napi_reject_deferred(env, deferred, JsError::from(e).into_value(env)) }; - debug_assert!(status == sys::Status::napi_ok, "Reject promise failed"); + debug_assert!( + status == sys::Status::napi_ok, + "Reject promise failedm status: {:?}", + crate::Status::from(status) + ); } }; } @@ -142,7 +150,8 @@ unsafe extern "C" fn complete( let delete_status = unsafe { sys::napi_delete_async_work(env, napi_async_work) }; debug_assert!( delete_status == sys::Status::napi_ok, - "Delete async work failed" + "Delete async work failed, status {:?}", + crate::Status::from(delete_status) ); work.status.store(1, Ordering::Relaxed); }