getOrElse
Returns the carried value, or what onFailure makes of the failure.
onFailure receives the whole DataResult.Failure rather than the exception inside it, so it can be returned as it stands - which is what makes the early exit out of a transaction block read the way it does:
val id = insertCitizen().getOrElse { return@transaction it }Content copied to clipboard
Return
The value on success, or the result of onFailure.
Parameters
onFailure
What to produce from a failure.