[WasmJs] Support catching JS exceptions
Fixed #KT-65660
This commit is contained in:
committed by
Space Team
parent
c6aac835e5
commit
8fe5cf2641
@@ -0,0 +1,42 @@
|
||||
// TARGET_BACKEND: WASM
|
||||
|
||||
fun throwSomeJsException(): Int = js("{ throw 42; }")
|
||||
|
||||
fun withFinally(): Boolean {
|
||||
try {
|
||||
throwSomeJsException()
|
||||
return false
|
||||
} finally {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun withThrowable(): Boolean {
|
||||
try {
|
||||
throwSomeJsException()
|
||||
return false
|
||||
} catch (_: Throwable) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun withJsException(): Boolean {
|
||||
try {
|
||||
throwSomeJsException()
|
||||
return false
|
||||
} catch (_: JsException) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
if (!withFinally()) return "FAIL1"
|
||||
if (!withThrowable()) return "FAIL2"
|
||||
if (!withJsException()) return "FAIL3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user