dbCatching

context(_: Raise<ErrorSpec>)
inline fun <T> dbCatching(block: () -> DbResult<T>): Either<DatabaseError, T>(source)

Executes a given database operation block, catching any potential errors and mapping them to a consistent error format. This method ensures robust error handling and encapsulates the result of the database operation in an Either type.

Return

An Either instance where the right side is the successful result of the database operation (T) and the left side is a mapped DatabaseError for any encountered errors.

Parameters

block

The database operation to execute, returning a DbResult containing either a success value of type T or a failure.