Skip to content

Commit

Permalink
Merge #2829
Browse files Browse the repository at this point in the history
2829: Improve error message oriented from JS object r=syrusakbary a=kateinoigakukun


<!-- 
Prior to submitting a PR, review the CONTRIBUTING.md document for recommendations on how to test:
https://github.com/wasmerio/wasmer/blob/master/CONTRIBUTING.md#pull-requests

-->

# Description
<!-- 
Provide details regarding the change including motivation,
links to related issues, and the context of the PR.
-->

`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.


# Review

- [ ] Add a short description of the change to the CHANGELOG.md file


Co-authored-by: Yuta Saito <[email protected]>
Co-authored-by: Syrus Akbary <[email protected]>
  • Loading branch information
3 people authored Mar 28, 2022
2 parents 8b47e10 + a446f4c commit 2ec7862
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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.
- [#2828](https://github.com/wasmerio/wasmer/pull/2828) Fix JsImportObject resolver.

## 2.2.1 - 2022/03/15
Expand Down
2 changes: 1 addition & 1 deletion lib/api/src/js/trap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
}
Expand Down

0 comments on commit 2ec7862

Please sign in to comment.