Checked Exceptions vs Unchecked Exceptions
There are two types of exceptions:
- Checked exceptions: the compiler forces you to catch them
- Unchecked exceptions: you are free to catch them or not
How does the compiler force you to handle checked exceptions?
Because Kotlin has no checked exceptions, we will use Java to demonstrate the behavior. A function signature can indicate exceptions that it may throw: