onError

inline fun <T> ApiResponse<T>.onError(crossinline onResult: ApiResponse.Failure.Error<T>.() -> Unit): ApiResponse<T>

Author

skydoves (Jaewoong Eum)

A scope function that would be executed for handling error responses if the request failed.

Return

The original ApiResponse.

Parameters

onResult

The receiver function that receiving ApiResponse.Failure.Exception if the request failed.


inline fun <T, V> ApiResponse<T>.onError(mapper: ApiErrorModelMapper<V>, crossinline onResult: V.() -> Unit): ApiResponse<T>

Author

skydoves (Jaewoong Eum)

A scope function that would be executed for handling error responses if the request failed with a ApiErrorModelMapper. This function receives a ApiErrorModelMapper and returns the mapped result into the scope.

Return

The original ApiResponse.

Parameters

mapper

The ApiErrorModelMapper for mapping ApiResponse.Failure.Error response as a custom V instance model.

onResult

The receiver function that receiving ApiResponse.Failure.Exception if the request failed.