diff options
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. |