Skip to content

Commit

Permalink
fix: getFileName can return null
Browse files Browse the repository at this point in the history
  • Loading branch information
devsnek committed Aug 5, 2024
1 parent c818185 commit 120e708
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,8 +1099,10 @@ pub mod callsite_fns {
};
// call getFileName
let orig_ret =
call_method::<v8::String>(scope, orig, super::GET_FILE_NAME, &[]);
if let Some(ret_val) = orig_ret {
call_method::<v8::Value>(scope, orig, super::GET_FILE_NAME, &[]);
if let Some(ret_val) =
orig_ret.and_then(|v| v.try_cast::<v8::String>().ok())
{
// strip off `file://`
let string = ret_val.to_rust_string_lossy(scope);
if let Some(file_name) = maybe_to_path_str(&string) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Error.prepareStackTrace = (err, frames) => {
return frames.map((frame) => frame.getFileName());
};

new Promise((_, reject) => {
reject(new Error("fail").stack);
}).catch((err) => {
console.log(err);
});
1 change: 1 addition & 0 deletions testing/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ integration_test!(
error_prepare_stack_trace,
error_with_stack,
error_without_stack,
error_get_file_name,
main_module_handler,
module_types,
pending_unref_op_tla,
Expand Down

0 comments on commit 120e708

Please sign in to comment.