Could something like a default error be defined i.e
@Throws(IOException::class)
fun readFile(name: String): String {
throw "Can not read file"
}
translated to
@Throws(IOException::class)
fun readFile(name: String): String {
throw IOException("Can not read file")
}
not default exactly but since we have already informed the compiler to expect an exception in the defined function why not have the throw by default initialize that error type
thus in the function
@Throws(IOException::class)
fun readFile(name: String): String {
if(true){
// section not affected by compiler as error initializer is defined
throw Error(message)
}else {
// section affected by the compiler as the error was defined by the annotation @Throws
// throwing IOException
throw message2
}
}