diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2020-04-10 17:26:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-10 18:26:52 +0200 |
commit | 8b4508338b15dcc08503553dc9179a154c0165c7 (patch) | |
tree | 82d3d283edcff994c5b998d0d948985dc04f1b8c /cli/fmt_errors.rs | |
parent | 195ad4c6264c3563044480685931999ffa9d3d5c (diff) |
fix(core/js_error): Get frame data from prepareStackTrace() (#4690)
Fixes: #2703
Fixes: #2710
Closes: #4153
Closes: #4232
Co-authored-by: Kevin (Kun) Kassimo Qian <kevinkassimo@gmail.com>
Diffstat (limited to 'cli/fmt_errors.rs')
-rw-r--r-- | cli/fmt_errors.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/cli/fmt_errors.rs b/cli/fmt_errors.rs index 5ba0bce77..b7cfbbce9 100644 --- a/cli/fmt_errors.rs +++ b/cli/fmt_errors.rs @@ -155,9 +155,21 @@ fn format_stack_frame(frame: &JSStackFrame, is_internal_frame: bool) -> String { source_loc = colors::gray(source_loc).to_string(); } if !frame.function_name.is_empty() { - format!("{} {} {}", at_prefix, function_name, source_loc) + if frame.is_async { + format!( + "{} {} {} {}", + at_prefix, + colors::gray("async".to_owned()).to_string(), + function_name, + source_loc + ) + } else { + format!("{} {} {}", at_prefix, function_name, source_loc) + } } else if frame.is_eval { format!("{} eval {}", at_prefix, source_loc) + } else if frame.is_async { + format!("{} async {}", at_prefix, source_loc) } else { format!("{} {}", at_prefix, source_loc) } @@ -272,6 +284,7 @@ mod tests { function_name: "foo".to_string(), is_eval: false, is_constructor: false, + is_async: false, }, JSStackFrame { line_number: 5, @@ -280,6 +293,7 @@ mod tests { function_name: "qat".to_string(), is_eval: false, is_constructor: false, + is_async: false, }, JSStackFrame { line_number: 1, @@ -288,8 +302,10 @@ mod tests { function_name: "".to_string(), is_eval: false, is_constructor: false, + is_async: false, }, ], + already_source_mapped: true, }; let formatted_error = JSError(core_js_error).to_string(); let actual = strip_ansi_codes(&formatted_error); |