getOrElse

inline fun <R, T : R> DecodingResult<T>.getOrElse(onFailure: (exception: Throwable) -> R): R

Returns the encapsulated value if this instance represents success or the result of onFailure for the encapsulated Throwable exception if it is failure.

Note, that this function rethrows any Throwable exception thrown by onFailure function.

Since

0.4.0


inline fun <R, T : R> DecodingResult<T>.getOrElse(onSchemaMismatch: (JsonElement, exception: Throwable) -> R, onFailure: (exception: Throwable) -> R): R

Returns the encapsulated value if this instance represents success, the result of onSchemaMismatch for the encapsulated JsonElement and Throwable if it is schema mismatch or the result of onFailure for the encapsulated Throwable if it is failure.

Note, that this function rethrows any Throwable exception thrown by onSchemaMismatch or onFailure.

Since

0.4.0