T
- the response body classpublic abstract class NetworkCallback<T> extends Object implements retrofit2.Callback<T>
Callback
's Response
and routes the server-provided errors to separate methodsModifier and Type | Class and Description |
---|---|
static class |
NetworkCallback.SpecificError
Holds the details of a
NetworkCallback.StNetworkException |
static class |
NetworkCallback.StNetworkException
Describes what type of network error occurred
|
Constructor and Description |
---|
NetworkCallback() |
Modifier and Type | Method and Description |
---|---|
abstract void |
onError(int httpStatusCode,
String errorMessage,
retrofit2.Call<T> call,
Throwable t)
Invoked when:
a network exception occurred talking to the server
an unexpected exception occurred creating the request or processing the response
a generic error occurred
|
void |
onFailure(retrofit2.Call<T> call,
Throwable t) |
void |
onResponse(retrofit2.Call<T> call,
retrofit2.Response<T> response) |
abstract void |
onSpecificError(NetworkCallback.StNetworkException networkException,
int httpStatusCode,
NetworkCallback.SpecificError error,
retrofit2.Call<T> call,
retrofit2.Response<T> response)
Invoked when a 400 or 406 application level failure occurred
|
abstract void |
onSuccess(retrofit2.Call<T> call,
retrofit2.Response<T> response)
Invoked for a successful response
|
public abstract void onSuccess(retrofit2.Call<T> call, retrofit2.Response<T> response)
call
- The Call
response
- The Response
public abstract void onError(int httpStatusCode, String errorMessage, retrofit2.Call<T> call, Throwable t)
httpStatusCode
- The http status codeerrorMessage
- An error message for this issuecall
- The Call
t
- The Throwable
associated to the issuepublic abstract void onSpecificError(NetworkCallback.StNetworkException networkException, int httpStatusCode, NetworkCallback.SpecificError error, retrofit2.Call<T> call, retrofit2.Response<T> response)
networkException
- The failure typehttpStatusCode
- The http status codeerror
- The failure detailscall
- The Call
response
- The Response
public final void onResponse(@NonNull retrofit2.Call<T> call, retrofit2.Response<T> response)
onResponse
in interface retrofit2.Callback<T>