[WASM] Implemented Wasm unhandled exceptions on JS site

This commit is contained in:
Igor Yakovlev
2022-01-21 17:00:30 +01:00
parent e32f9eb2ce
commit 0acb1c0c05
6 changed files with 198 additions and 19 deletions
@@ -0,0 +1,24 @@
/*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package kotlin.wasm.internal
@JsFun(
"""(message, wasmTypeName, stack) => {
const error = new Error();
error.message = message;
error.name = wasmTypeName;
error.stack = stack;
throw error;
}"""
)
private external fun throwJsError(message: String?, wasmTypeName: String?, stack: String)
internal fun throwAsJsException(t: Throwable): Nothing {
throwJsError(t.message, t::class.simpleName, t.stackTraceToString())
return error("Unreachable")
}
internal var isNotFirstWasmExportCall: Boolean = false