try is an expression:
val a: Int? = try { input.toInt() } catch (e: NumberFormatException) { null }
More sugar:
require(count >= 0) { "Count must be non-negative, was $count" }
// IllegalArgumentException
error("Error message")
// IllegalStateException
Thanx!
Throwable
Error
Exception
Error subclasses
RuntimeException
ArithmeticException
Right column: direct Exception subclasses
ARROWS
Error -> Throwable
AssertionError -> Error
RuntimeException -> Exception
Direct Exception subclasses -> Exception (routed via vertical spine at x=790)