From 7adcfef4e721f17a0726f6c338a8a0903bddff03 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sun, 27 Mar 2022 16:22:15 +0000 Subject: [PATCH] Improve error message oriented from JS object `JsValue.as_string` converts the value to String iff the value is a String itself, so the error message always failovers to empty string. `JsValue` impls `Debug` using `JSON.stringify`, and it gives better description of the error. --- CHANGELOG.md | 3 +++ lib/api/src/js/trap.rs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e400e2dd832..222e374608b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ Looking for changes that affect our C API? See the [C API Changelog](lib/c-api/C ## **Unreleased** +### Fixed +- [#2829](https://github.com/wasmerio/wasmer/pull/2829) Improve error message oriented from JS object. + ## 2.2.1 - 2022/03/15 ### Fixed diff --git a/lib/api/src/js/trap.rs b/lib/api/src/js/trap.rs index 5bcde356c7e..88a8d6d0979 100644 --- a/lib/api/src/js/trap.rs +++ b/lib/api/src/js/trap.rs @@ -43,7 +43,7 @@ impl fmt::Display for RuntimeErrorSource { match self { Self::Generic(s) => write!(f, "{}", s), Self::User(s) => write!(f, "{}", s), - Self::Js(s) => write!(f, "{}", s.as_string().unwrap_or("".to_string())), + Self::Js(s) => write!(f, "{:?}", s), } } }