invoke

inline operator fun <T> invoke(value: T): ApiResult<T>

Create an ApiResult instance using the given value. When value is an Exception, an error result will be created. Otherwise, a success result will be created.

If you want to directly create a success value of an Exception, use Success


inline operator fun <T> invoke(call: () -> T): ApiResult<T>

Execute call, catching any exceptions, and wrap it in an ApiResult.

Caught exceptions are mapped to ApiResult.Errors. Throwables are not caught on purpose. CancellationExceptions are rethrown.


inline operator fun invoke(): ApiResult<Unit>

Returns an ApiResult value. Use this for applying operators such as require and mapWrapping to build chains of operators that should start with an empty value.