Error

data class Error<T>(val response: Response<T>) : ApiResponse.Failure<T>

API response error case. API communication conventions do not match or applications need to handle errors. e.g., internal server error.

Parameters

response

A response from OkHttp request call.

Constructors

Link copied to clipboard
fun <T> Error(response: Response<T>)

Properties

Link copied to clipboard
val errorBody: ResponseBody?

The ResponseBody can be consumed only once.

Link copied to clipboard
val headers: Headers

The header fields of a single HTTP message.

Link copied to clipboard
val raw: Response

The raw response from the HTTP client.

Link copied to clipboard
val response: Response<T>
Link copied to clipboard
val statusCode: StatusCode

StatusCode is Hypertext Transfer Protocol (HTTP) response status codes.

Functions

Link copied to clipboard
open override fun toString(): String

Extensions

Link copied to clipboard
fun <T, V> ApiResponse.Failure.Error<T>.map(mapper: ApiErrorModelMapper<V>): V
fun <T, V> ApiResponse.Failure.Error<T>.map(mapper: (ApiResponse.Failure.Error<T>) -> V): V
inline fun <T, V> ApiResponse.Failure.Error<T>.map(mapper: ApiErrorModelMapper<V>, crossinline onResult: V.() -> Unit)
Link copied to clipboard
fun <T> ApiResponse.Failure.Error<T>.message(): String
Link copied to clipboard
inline suspend fun <T, V> ApiResponse.Failure.Error<T>.suspendMap(mapper: ApiErrorModelMapper<V>, crossinline onResult: suspend V.() -> Unit)
inline suspend fun <T, V> ApiResponse.Failure.Error<T>.suspendMap(crossinline mapper: suspend (ApiResponse.Failure.Error<T>) -> V): V