[browser] avoid undefined stack (#80707)
authorPavel Savara <pavel.savara@gmail.com>
Tue, 17 Jan 2023 11:08:46 +0000 (12:08 +0100)
committerGitHub <noreply@github.com>
Tue, 17 Jan 2023 11:08:46 +0000 (12:08 +0100)
src/mono/wasm/runtime/logging.ts

index cdb2d00dba723dd2996685c5d52392ec54d16a32..4a2f0e326255ec1b3d5c81b1da83cbf24bf70f93 100644 (file)
@@ -62,8 +62,8 @@ export function mono_wasm_symbolicate_string(message: string): string {
 
 export function mono_wasm_stringify_as_error_with_stack(err: Error | string): string {
     let errObj: any = err;
-    if (!(errObj instanceof Error)) {
-        errObj = new Error(errObj);
+    if (!errObj || !errObj.stack || !(errObj instanceof Error)) {
+        errObj = new Error(errObj || "Unknown error");
     }
 
     // Error