runCatchingLogging

inline fun <T, R> R.runCatchingLogging(noinline errorMessageBuilder: R.(Throwable) -> Any = { "Something web wrong" }, logger: KSLog = KSLog, block: R.() -> T): Result<T>(source)

Executes the given block within a runCatching context and logs any exceptions that occur, excluding CancellationException which is rethrown. This method simplifies error handling by automatically logging the errors using the provided logger.

Return

A Result representing the outcome of executing the block.

Parameters

errorMessageBuilder

A lambda to build the error log message. By default, it returns a generic error message.

logger

The logging instance used for logging errors. Defaults to KSLog.

block

The code block to execute within the runCatching context.

Type Parameters

T

The result type of the block.

R

The receiver type on which this function operates.