toDbResult

Converts a Kotlin Result to Either.

If the Result contains a SQLError, it's used as-is. Otherwise, the exception is wrapped (as the cause) in a SQLError with UnknownError code.

A cancellation is not a database error and is rethrown, like Arrow's own Either.catch does: as a Left, the caller's retry or fallback logic would carry on in a coroutine that was cancelled (or timed out).

Return

Either.Right with the success value, or Either.Left with SQLError

Throws

if the Result failed with one