https://kotlinlang.org logo
Title
s

sindrenm

11/21/2018, 2:56 PM
Hmm, Kotlin (on the JVM in this case) defines some new exceptions and also aliases some of Java's exceptions (like
kotlin.RuntimeException
is actually just a typealias for
java.lang.RuntimeException
). And all of Kotlin's own exceptions will ultimately inherit from
kotlin.Throwable
, whereas Java's exceptions will inherit from
java.lang.Throwable
). But does that mean that catching
kotlin.Throwable
only won't actually catch e.g. `java.lang.RuntimeException`s?
d

diesieben07

11/21/2018, 3:01 PM
s

sindrenm

11/21/2018, 3:02 PM
Oh, interesting! I just navigated to
kotlin.Throwable
in the IDE and saw this, which made me wonder.
public open class Throwable(open val message: String?, open val cause: Throwable?) {
    // ...
}
Thanks!
d

diesieben07

11/21/2018, 3:03 PM
Yeah, there is some compiler magic going on for some of the mapped types.
s

sindrenm

11/21/2018, 3:03 PM
Also, I should've just tried it out in a REPL or something before asking. Was easy enough to find that it got caught as I expected it to. 😒imple_smile:
Then my problem is something else mysterious. I seem to be getting `java.lang.NullPointerException`s thrown around even if I am catching
kotlin.Throwable
from that call-site. Oh well, back to the drawing board. Thanks, @diesieben07! :D