-
-
Save marrek13/467be212bd60c38b8883f65cca58b0b9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <T: Any> NetworkResponse<T, DetailsError>.call(): T { | |
return when (this) { | |
is NetworkResponse.Success<T> -> this.body | |
is NetworkResponse.ServerError<DetailsError> -> throw CatalogIOException(this.body?.message.orEmpty(), this.code, this.error) | |
is NetworkResponse.NetworkError -> throw CatalogIOException("Network error", 500, this.error) | |
is NetworkResponse.UnknownError -> throw CatalogIOException("Unknown error", 500, this.error) | |
is NetworkResponse.Error -> throw CatalogIOException("Unknown exception", 500, this.error) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment