on

inline fun <T : Throwable> Block.on(code: (T) -> Unit)

evaluates the supplied code block if the receiver block execution throws an exception of type T.

Parameters

<receiver>

Block

T

generic parameter which must implements Throwable interface

code

block of code to execute if caught Exception of type T

inline fun <T : Throwable> Closure.on(code: (T) -> Unit): Any?

evaluates the supplied code block if the receiver block execution throws an exception of type T.

Return

Any?

Parameters

<receiver>

Closure

T

generic parameter which must implements Throwable interface

code

block of code to execute if caught Exception of type T

inline fun <T : Throwable> Block.on(code: (T) -> Unit, ensure: Block)

evaluates the supplied code block if the receiver block execution throws an exception of type T, and always evaluates the second code block.

Parameters

<receiver>

Block

T

generic parameter which must implements Throwable interface

code

block of code to execute if caught Exception of type T

ensure

block of code to always execute

inline fun <T : Throwable> Closure.on(code: (T) -> Unit, ensure: Block): Any?

evaluates the supplied code block if the receiver closure execution throws an exception of type T, and always evaluates the second code block.

Return

Any?

Parameters

<receiver>

CLosure

T

generic parameter which must implements Throwable interface

code

block of code to execute if caught Exception of type T

ensure

block of code to always execute