BasicResultBlock

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Functions

Link copied to clipboard
inline fun <R, E : Exception> ResultBlock<R, E>.ensure(predicate: Boolean, block: () -> E)

If the predicate evaluates to true, then throw the exception form the body. This should usually be called in a "catching" block.

Link copied to clipboard
inline fun <R, E : Exception> ResultBlock<R, E>.ensureNotNull(predicate: Any?, block: () -> E)

If the predicate is null, then throw the exception form the body. This should usually be called in a "result" block.

Link copied to clipboard
fun <R, E : Exception> ResultBlock<R, E>.failWith(block: () -> E): Nothing

Type safe way of throwing an exception.

Link copied to clipboard
fun <R, E : Exception> ResultBlock<R, E>.finally(block: (Result<R, E>) -> Unit)

Defines a block of code that is always called after result block has finished. The block is always executed even on failures caused by undefined Throwables or Exceptions.