From afdd4060ab0ed69dd065c6bb0b23ceaf72d262a3 Mon Sep 17 00:00:00 2001 From: stefan-gorules <127550877+stefan-gorules@users.noreply.github.com> Date: Thu, 2 Nov 2023 10:30:50 +0100 Subject: [PATCH] fix(napi): js promise error messages (#1672) --- crates/napi/src/error.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/napi/src/error.rs b/crates/napi/src/error.rs index 1d543da2..6f8a5d79 100644 --- a/crates/napi/src/error.rs +++ b/crates/napi/src/error.rs @@ -90,6 +90,18 @@ impl From for Error { "Create Error reference failed".to_owned(), ); } + + let maybe_error_message = value + .coerce_to_string() + .and_then(|a| a.into_utf8().and_then(|a| a.into_owned())); + if let Ok(error_message) = maybe_error_message { + return Self { + status: Status::GenericFailure, + reason: error_message, + maybe_raw: result, + }; + } + Self { status: Status::GenericFailure, reason: "".to_string(),