~I just noticed that `shouldThrow<SomeException...
# kotest
b
I just noticed that
shouldThrow<SomeException>
won't match if a sub-type of
SomeException
is thrown. But when I try and test with code equivalent(?) to what's in
shouldThrow
, it does match.
I'm an idiot. Nothing to see here.
My test:
Copy code
sealed class MyException : Exception() {
    sealed class SubException : MyException() {
        class SubSubException : SubException()
    }
}

inline fun <reified T : Throwable> baz() {
    try {
        throw MyException.SubException.SubSubException()
    } catch (t: Throwable) {
        when (t) {
            is T -> {
                println("my exception thrown!")
            }
            else -> {
                println("don't recognize it!")
            }
        }
    }
}
This prints
my exception thrown!
as I'd expect
🤦 Shit. Ignore me.
😂 2
l
Happens to all of us 😂