diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2020-10-08 10:05:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-08 11:05:19 +0200 |
commit | 986ad08bce7781e17f98d17d223033a2eb0785af (patch) | |
tree | 02d3168c9f3619690c667be11730cde9de22ca34 /core/error.rs | |
parent | 62f8d945e1e32727d8905b0e3eff4854a3b47e10 (diff) |
fix(cli/rt/error_stack): Improve message line formatting (#7860)
Diffstat (limited to 'core/error.rs')
-rw-r--r-- | core/error.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/core/error.rs b/core/error.rs index 1aa67e26c..30aa88773 100644 --- a/core/error.rs +++ b/core/error.rs @@ -174,14 +174,24 @@ impl JsError { // Get the message by formatting error.name and error.message. let name = get_property(scope, exception, "name") + .filter(|v| !v.is_undefined()) .and_then(|m| m.to_string(scope)) .map(|s| s.to_rust_string_lossy(scope)) - .unwrap_or_else(|| "undefined".to_string()); + .unwrap_or_else(|| "Error".to_string()); let message_prop = get_property(scope, exception, "message") + .filter(|v| !v.is_undefined()) .and_then(|m| m.to_string(scope)) .map(|s| s.to_rust_string_lossy(scope)) - .unwrap_or_else(|| "undefined".to_string()); - let message = format!("Uncaught {}: {}", name, message_prop); + .unwrap_or_else(|| "".to_string()); + let message = if name != "" && message_prop != "" { + format!("Uncaught {}: {}", name, message_prop) + } else if name != "" { + format!("Uncaught {}", name) + } else if message_prop != "" { + format!("Uncaught {}", message_prop) + } else { + "Uncaught".to_string() + }; // Access error.stack to ensure that prepareStackTrace() has been called. // This should populate error.__callSiteEvals. |