Be a bit more specific when feature detecting Javascipt errors (#1647)

This commit is contained in:
Hood Chatham 2021-06-19 01:55:57 -07:00 committed by GitHub
parent 5d4ff86a7c
commit 2dd41b639b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -604,7 +604,10 @@ EM_JS_NUM(bool, hiwire_is_comlink_proxy, (JsRef idobj), {
EM_JS_NUM(bool, hiwire_is_error, (JsRef idobj), {
// From https://stackoverflow.com/a/45496068
let value = Module.hiwire.get_value(idobj);
return !!(value && value.stack && value.message);
// clang-format off
return !!(value && typeof value.stack === "string" &&
typeof value.message === "string");
// clang-format on
});
EM_JS_NUM(bool, hiwire_is_promise, (JsRef idobj), {