lightweight_result library

Classes

Result<T, E>

Extensions

ResultAnd
ResultFactory
Converts a nullable of type T to a Result. Returns a success if the value is non-null, otherwise the supplied error.
ResultGet
ResultMap
ResultOn
ResultOr
ResultUnwrap

Functions

runCatching<T>(T block()) Result<T, Exception>
Calls the specified function block and returns its encapsulated result if invocation was successful, catching and encapsulating any thrown exception as a failure.
runCatchingAsync<T>(Future<T> block()) Future<Result<T, Exception>>
Calls and await the specified function block and returns its encapsulated result if invocation was successful, catching and encapsulating any thrown exception as a failure.
zip2<T1, T2, T, E>(Result<T1, E> result1(), Result<T2, E> result2(), T transform(T1, T2)) Result<T, E>
Apply a transform to two Result, if both Result are Ok. If not, the first argument which is an Err will propagate through.
zip3<T1, T2, T3, T, E>(Result<T1, E> result1(), Result<T2, E> result2(), Result<T3, E> result3(), T transform(T1, T2, T3)) Result<T, E>
Apply a transform to three Result, if all Result are Ok. If not, the first argument which is an Err will propagate through.
zip4<T1, T2, T3, T4, T, E>(Result<T1, E> result1(), Result<T2, E> result2(), Result<T3, E> result3(), Result<T4, E> result4(), T transform(T1, T2, T3, T4)) Result<T, E>
Apply a transform to four Result, if all Result are Ok. If not, the first argument which is an Err will propagate through.
zip5<T1, T2, T3, T4, T5, T, E>(Result<T1, E> result1(), Result<T2, E> result2(), Result<T3, E> result3(), Result<T4, E> result4(), Result<T5, E> result5(), T transform(T1, T2, T3, T4, T5)) Result<T, E>
Apply a transform to five Result, if all Result are Ok. If not, the first argument which is an Err will propagate through.

Exceptions / Errors

UnwrapException