tryCatch

fun <T, U, E : Throwable> T.tryCatch(catchOn: KClass<E>, body: (T) -> U): U?

Tries a function method on T, returns null if the exception was the instance of E.

Return

The result from the body function as U.

Parameters

catchOn

The exception to catch on.

body

The body function to call.