countExceptions

suspend fun <T> Counter.countExceptions(vararg exceptionTypes: KClass<out Throwable>, block: () -> T): T?
suspend fun <T> Counter.Child.countExceptions(vararg exceptionTypes: KClass<out Throwable>, block: () -> T): T?

Executes the given block and increments the counter if an exception of the specified types is thrown.

Return

The result of the block, or null if an exception is caught.

Parameters

exceptionTypes

The types of exceptions to count. If empty, all exceptions are counted.

block

The block of code to execute.