Reputation: 369
fun fun1(id: String)
{
addThings(3,4)
}
fun addThings(num1: Int, num2: Int)
{
addNumbers(num1, num2)
}
@Throws(Exception::class)
fun addNumbers(num1: Int, num2: Int)
{
throws Exception("error")
}
Excption
from addNumbers
will bubble up all the way to fun1
is that right?@Throws
required for addThings
and fun1
?Couldn't find any docs online...
Upvotes: 0
Views: 1627
Reputation: 1451
No.
You can find good documentation on this here.
In summary, Kotlin does not have checked exceptions. That means there is no "bubble up". There is no requirement for any of your functions to declare that they throw an exception or to use try-catch. Declaring the annotation @Throws is only strictly necessary for Java interop, you may need it if you call that Kotlin function from a Java file.
You can read about why from Kotlin's project lead Roman Elizarov.
Upvotes: 3