db

context(_: Raise<ErrorSpec>)
inline fun <T> db(block: () -> DbResult<T>): T(source)

Executes a database operation within a safe context, raising errors as specified by the ErrorSpec interface.

This function wraps a database operation block and processes potential errors using dbCatching. The result is unwrapped and returned to the caller, assuming the operation succeeds. If the operation fails, an error is raised within the context of the ErrorSpec.

Return

The result of the database operation, of generic type T, if the operation is successful.

Parameters

block

The lambda expression representing the database operation to be executed.