Class ErrorResponse
-
- All Implemented Interfaces:
-
com.inmobi.media.network.okhttp.NetworkResponse
public final class ErrorResponse implements NetworkResponse
Class representing an error response from a network operation.
-
-
Constructor Summary
Constructors Constructor Description ErrorResponse(String url, ErrorCode errorCode)
-
Method Summary
Modifier and Type Method Description IntegergetStatusCode()Retrieves the status code of the HTTP response. StringgetError()Retrieves the error associated with the response. ByteStringgetByteString()Retrieves the response as a ByteString. <T extends Any> TgetResponse(Class<T> responseModelClass)Retrieves the response parsed into the specified type asynchronously. <T extends Any> TgetResponse(Class<T> responseModelClass, Function1<String, String> modifyResponse)Retrieves the response parsed into the specified type asynchronously. NetworkMetaDatagetMetadata()Retrieves the metadata associated with the network response. StringgetUrl()Retrieves the url associated with the network request. -
-
Method Detail
-
getStatusCode
Integer getStatusCode()
Retrieves the status code of the HTTP response. For an ErrorResponse, this is the integer value of the errorCode.
- Returns:
The status code.
-
getError
String getError()
Retrieves the error associated with the response. For an ErrorResponse, this is the name of the errorCode enum constant.
- Returns:
The error message.
-
getByteString
ByteString getByteString()
Retrieves the response as a ByteString. For an ErrorResponse, this is always an empty ByteString.
- Returns:
The empty ByteString representation of the response.
-
getResponse
<T extends Any> T getResponse(Class<T> responseModelClass)
Retrieves the response parsed into the specified type asynchronously. For an ErrorResponse, this returns null.
- Parameters:
responseModelClass- The class of the response model to parse into.- Returns:
A Deferred result containing the parsed response, or null if parsing fails.
-
getResponse
<T extends Any> T getResponse(Class<T> responseModelClass, Function1<String, String> modifyResponse)
Retrieves the response parsed into the specified type asynchronously. For an ErrorResponse, this returns null.
- Parameters:
responseModelClass- The class of the response model to parse into.modifyResponse- A function to modify the response string before parsing.- Returns:
A Deferred result containing the parsed response, or null if parsing fails.
-
getMetadata
NetworkMetaData getMetadata()
Retrieves the metadata associated with the network response. For an ErrorResponse, this provides default empty metadata.
- Returns:
The metadata of the network response.
-
-
-
-