Merge pull request #1466 from fitzgen/log-stacks

Log stacks of imported JS functions that throw but aren't marked `catch`
This commit is contained in:
Alex Crichton 2019-05-01 16:51:50 -05:00 committed by GitHub
commit 358ee18ab2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -716,13 +716,23 @@ impl<'a, 'b> Rust2Js<'a, 'b> {
try {{\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:\", \
e);
error);
throw e;
}}\
",
&invoc,
shim,
);
}