How to catch non kotlin exception?


kotlin generates type check in js catch block and rethrows if it fails. Is it possible to write non Throwable catch in kotlin without js("")?


Kotlin Throwable is mapped to js Error. Or do you mean that non-Kotlin exception is not an Error?


After some experimentation I discovered it is possible to do this

fun catchMe() {
    try {
        js("throw 'Some text'")
    } catch(e: dynamic) {

Which generates js code I was searching for. Is it supported or I found a bug?

btw. What about C++/ SEH on native platforms. From my memories it is possible to throw anything. native will have dynamyc/**Any for integration?


Cathing dynamic exception is a feature that was made intentionally. It’s desgined specially for catching exceptions that are not inherited from JavaScript Error.