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.
This commit is contained in:
Yuta Saito
2022-03-27 16:22:15 +00:00
parent a8a3412555
commit 7adcfef4e7
2 changed files with 4 additions and 1 deletions

View File

@@ -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),
}
}
}