trustweaveCatching

inline suspend fun <T> trustweaveCatching(crossinline block: suspend () -> T): Result<T>

Executes a suspend block and automatically converts any exceptions to TrustWeaveException.

This is a convenience function that combines runCatching with automatic error conversion, reducing boilerplate in API methods.

Example:

suspend fun performOperation(): Result<ResultType> = trustweaveCatching {
// operation that might throw
someService.performOperation(options)
}

Note: The error conversion transforms any Throwable to a TrustWeaveException, so the type system allows this transformation.

Cancellation: a CancellationException thrown by block (coroutine cancellation, including enclosing withTimeout) is rethrown — never captured or converted — so structured concurrency keeps working through this helper.

Return

Result with the block result or a TrustWeaveException

Parameters

block

The suspend block to execute