NetworkException

Return type to signify that an error has occurred. The type returned indicates what type of error has occurred, and the isRetryable implementation will indicate if it is safe to retry the request.

Where a response was received before the request failed, it is available on httpResponse for further inspection of the failure.

Parameters

httpResponse

The response received before the failure - e.g. the response headers, or an error body returned by the server. It is null where the request failed before any response was received, and may be missing its HttpResponse.body, as reading the body is best-effort only.

See also

Inheritors

Types

Link copied to clipboard

Indicates that the request was canceled by the requester. It is therefore unknown whether it is safe to retry the request, so it is deemed not safe to retry.

Link copied to clipboard
class NetworkIOException @JvmOverloads constructor(cause: IOException?, val httpResponse: HttpResponse? = null) : NetworkException

Indicates that the request failed with an IOException - possibly due to loss of connectivity before the connection was opened, or while reading the response. This type of error can always be retried, as the request never completed.

Link copied to clipboard
class Non200Exception @JvmOverloads constructor(val statusCode: Int, val httpResponse: HttpResponse? = null) : NetworkException

Indicates that the response was a non-2XX HTTP status code. Whether the request can be retried is determined by the statusCode.

Link copied to clipboard
class UnexpectedException @JvmOverloads constructor(cause: Throwable?, val httpResponse: HttpResponse? = null) : NetworkException

Indicates that a network request failed for an unknown reason. It is therefore unknown whether it is safe to retry the request, so it is deemed not safe to retry.

Properties

Link copied to clipboard
open val cause: Throwable?
Link copied to clipboard
Link copied to clipboard
open val message: String?

Functions

Link copied to clipboard
abstract fun isRetryable(): Boolean