Exception Types and Their Hierarchy

Learn how to handle common exception types and understand the exception hierarchy.

Exception types

A few types of exceptions are defined in Kotlin that we use in certain situations. Some of the most important ones are:

  • IllegalArgumentException: We use this when an argument has an incorrect value. For example, when we expect our argument value to be bigger than zero but it is not.

  • IllegalStateException: We use this when the state of our system is incorrect. This means the values of properties are not accepted by a function call.

Get hands-on with 1400+ tech skills courses.