asThrowable

inline fun <T> T.asThrowable(fallbackMessage: (T) -> String = { "$it was converted into a Throwable!" }): Throwable

Converts any value of type T to a Throwable:

Return

A Throwable representing T.

Parameters

fallbackMessage

Produces the exception message from the receiver value. Defaults to a generic description. Only used when the receiver is not already a Throwable or ThrowableWrapper — in those cases the existing exception is returned as-is and this parameter is ignored.