diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2022-05-08 18:03:00 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-08 23:03:00 +0200 |
commit | d0f5cd6a069e6a416e58b4ece456d134135b11d3 (patch) | |
tree | 31365ff5d8fd0ad76be95b1ca3930a1aeeb88920 /core/error.rs | |
parent | bcd875030a2774a74051ef006c4a66436d43b3fa (diff) |
fix(core): avoid panic on non-string Error.name (#14529)
Fixes #14518
Diffstat (limited to 'core/error.rs')
-rw-r--r-- | core/error.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/error.rs b/core/error.rs index 045dd5a15..2ba053802 100644 --- a/core/error.rs +++ b/core/error.rs @@ -164,7 +164,7 @@ fn get_property<'a>( object.get(scope, key.into()) } -#[derive(serde::Deserialize)] +#[derive(Default, serde::Deserialize)] pub(crate) struct NativeJsError { pub name: Option<String>, pub message: Option<String>, @@ -196,7 +196,7 @@ impl JsError { let exception: v8::Local<v8::Object> = exception.try_into().unwrap(); let cause = get_property(scope, exception, "cause"); let e: NativeJsError = - serde_v8::from_v8(scope, exception.into()).unwrap(); + serde_v8::from_v8(scope, exception.into()).unwrap_or_default(); // Get the message by formatting error.name and error.message. let name = e.name.clone().unwrap_or_else(|| "Error".to_string()); let message_prop = e.message.clone().unwrap_or_else(|| "".to_string()); |