Skip to content

Instantly share code, notes, and snippets.

@timusus
Last active October 20, 2018 03:57
Show Gist options
  • Save timusus/8edd521b8af477e100824b1c99c377ab to your computer and use it in GitHub Desktop.
Save timusus/8edd521b8af477e100824b1c99c377ab to your computer and use it in GitHub Desktop.
ResponseMapperSnippet
override fun onResponse(call: Call<T>, response: Response<T>) {
if (call.isCanceled) return
if (response.isSuccessful) {
callback(Result.Success(response.body()))
} else {
callback(Result.Failure(responseErrorMapper?.invoke(response) ?: RemoteServiceHttpError(response)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment