Package-level declarations

Types

Link copied to clipboard
value class RestResult<out T>

Encapsulates a successful outcome or a failure.

Functions

Link copied to clipboard
suspend fun <R> RestAction<R>.awaitCatching(): RestResult<R>

Awaits the completion of this RestAction and wraps it in a Result.

Link copied to clipboard
suspend fun <R> RestAction<*>.awaitNull(): R?

Awaits the completion of this RestAction and returns null.

Link copied to clipboard
suspend fun <R> RestAction<R>.awaitOrNullOn(ignored: ErrorResponse, vararg errorResponses: ErrorResponse): R?

Awaits the completion of this RestAction, returns null if one of the provided error responses was thrown.

Link copied to clipboard
suspend fun RestAction<*>.awaitUnit()

Awaits the completion of this RestAction.

Link copied to clipboard
inline fun <T> RestResult<T>.handle(predicate: (Throwable) -> Boolean, block: (Throwable) -> Unit): RestResult<T>

Dismisses the encapsulated exception and runs the given block if it matches the predicate.

inline fun <T> RestResult<T>.handle(type: KClass<out Throwable>, vararg types: KClass<out Throwable>, block: (Throwable) -> Unit): RestResult<T>

Dismisses the encapsulated exception and runs the given block if it corresponds to an ignored exception type.

inline fun <T> RestResult<T>.handle(type: ErrorResponse, vararg responses: ErrorResponse, block: (ErrorResponseException) -> Unit): RestResult<T>

Dismisses the encapsulated exception and runs the given block if it corresponds to an ignored response.

Link copied to clipboard
inline fun <T> RestResult<T>.ignore(predicate: (Throwable) -> Boolean): RestResult<T>

Dismisses the encapsulated exception if it corresponds to the predicate.

fun <T> RestResult<T>.ignore(ignored: KClass<out Throwable>, vararg types: KClass<out Throwable>): RestResult<T>

Dismisses the encapsulated exception if it corresponds to an ignored exception.

fun <T> RestResult<T>.ignore(ignored: ErrorResponse, vararg responses: ErrorResponse): RestResult<T>

Dismisses the encapsulated error response if it corresponds to an ignored response.

Link copied to clipboard

Runs the given block if the result is an error response.

Runs the given block if the result is the specified error response.

Link copied to clipboard

Runs the given block if the result is an ErrorResponseException.

Link copied to clipboard
fun RestAction<*>.queueIgnoring(ignored: ErrorResponse, vararg errorResponses: ErrorResponse)

Queues this REST action while ignoring the provided error responses.

Link copied to clipboard
inline fun <T : R, R> RestResult<T>.recover(predicate: (Throwable) -> Boolean, block: (Throwable) -> R): RestResult<R>

Maps the encapsulated exception using the given block if it corresponds to the predicate.

inline fun <T : R, R> RestResult<T>.recover(type: KClass<out Throwable>, vararg types: KClass<out Throwable>, block: (Throwable) -> R): RestResult<R>

Maps the encapsulated exception using the given block if it corresponds to an ignored exception type.

inline fun <T : R, R> RestResult<T>.recover(response: ErrorResponse, vararg responses: ErrorResponse, block: (ErrorResponseException) -> R): RestResult<R>

Maps the encapsulated exception using the given block if it corresponds to an ignored response.

Link copied to clipboard
inline fun <R> runCatchingResponse(ignored: ErrorResponse, vararg ignoredResponses: ErrorResponse, block: () -> R): RestResult<R>

Encapsulates the result of the specified function block and dismisses error responses that corresponds to an ignored response, making the Result a success.

Link copied to clipboard
inline fun <T> runCatchingRest(block: () -> T): RestResult<T>

Calls the specified function block and returns its encapsulated result if invocation was successful, catching any Throwable exception that was thrown from the block function execution and encapsulating it as a failure.

Link copied to clipboard
inline fun runIgnoringResponse(ignored: ErrorResponse, vararg ignoredResponses: ErrorResponse, block: () -> Unit)

Runs the specified function block and dismisses error responses that corresponds to an ignored response.

Link copied to clipboard
inline fun <R> runIgnoringResponseOrNull(ignored: ErrorResponse, vararg ignoredResponses: ErrorResponse, block: () -> R): R?

Runs the specified function block and returns null on error responses that corresponds to an ignored response.