As with Java and some other programming languages, Kotlin uses try
and catch
to help deal with possible exceptions. You wrap the code that might raise an
exception in try
, and you then chain a catch
block to deal with an exception
if one is raised. The catch
block gets the exception (e
in this case) and
can use it, such as printing it as we are doing here.
You can learn more about this in:
Tags: