When using kotlin exception in swift, we can't che...
# kotlin-native
s
When using kotlin exception in swift, we can't check their type ? Either throwed from Kotlin or throwed from swift ?
Copy code
do {
	//try Library.companion.getData()
	throw SealedClass.NotInitialized().asError()
}
catch let error as SealedClass {
	print("SealedClass")
}
catch let error as SealedClass.NotInitialized {
	print("NotInitialized")
}
catch let error {
	print("It's another type\(error)")
}
e
Kotlin throwables are wrapped as
NSError
to be thrown to ObjC (which Swift handles as
Error
). you can unwrap with the extension
Copy code
do {
    //try Library.companion.getData()
    throw SealedClass.NotInitialized().asError()
} catch error {
    switch error.kotlinException {
        case as SealedClass.NotInitialized:
            print("NotInitialized")
        case as SealedClass:
            print("SealedClass")
        default:
            print("It's another type\(error)")
    }
}