mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-31 01:11:06 +00:00
Log stacks of imported JS functions that throw but are not marked catch
Particularly useful in our tests, where we don't have the regular console logging with post-facto object inspection, and instead need to provide all this info up front.
This commit is contained in:
parent
10cbc789a8
commit
805aaa2273
@ -716,13 +716,23 @@ impl<'a, 'b> Rust2Js<'a, 'b> {
|
|||||||
try {{\n\
|
try {{\n\
|
||||||
{}
|
{}
|
||||||
}} catch (e) {{\n\
|
}} catch (e) {{\n\
|
||||||
console.error(\"wasm-bindgen: imported JS function that \
|
let error = (function () {{
|
||||||
|
try {{
|
||||||
|
return e instanceof Error
|
||||||
|
? `${{e.message}}\n\nStack:\n${{e.stack}}`
|
||||||
|
: e.toString();
|
||||||
|
}} catch(_) {{
|
||||||
|
return \"<failed to stringify thrown value>\";
|
||||||
|
}}
|
||||||
|
}}());
|
||||||
|
console.error(\"wasm-bindgen: imported JS function `{}` that \
|
||||||
was not marked as `catch` threw an error:\", \
|
was not marked as `catch` threw an error:\", \
|
||||||
e);
|
error);
|
||||||
throw e;
|
throw e;
|
||||||
}}\
|
}}\
|
||||||
",
|
",
|
||||||
&invoc,
|
&invoc,
|
||||||
|
shim,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user