fix(napi): js promise error messages (#1672)

This commit is contained in:
stefan-gorules 2023-11-02 10:30:50 +01:00 committed by LongYinan
parent 3a1a280d5f
commit afdd4060ab
No known key found for this signature in database
GPG key ID: C3666B7FC82ADAD7

View file

@ -90,6 +90,18 @@ impl From<JsUnknown> 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(),