NetworkError

sealed class NetworkError : Exception

The error type surfaced by NetworkClient. Mirrors SwiftyNetwork's NetworkError.

Every failure a request can produce is mapped onto one of these cases, so callers can branch on a closed set instead of inspecting raw transport exceptions.

Inheritors

Types

Link copied to clipboard

A 401 was received and the authorization provider could not refresh the credential.

Link copied to clipboard

The response body failed to decode into the requested type.

Link copied to clipboard

The request body failed to encode.

Link copied to clipboard
data object Forbidden : NetworkError

HTTP 403.

Link copied to clipboard

The response body was missing or unreadable.

Link copied to clipboard

The response could not be interpreted as HTTP.

Link copied to clipboard
data class InvalidUrl(val url: String) : NetworkError

The endpoint produced a malformed URL.

Link copied to clipboard

The device appears to be offline / the host was unreachable.

Link copied to clipboard
data object NotFound : NetworkError

HTTP 404.

Link copied to clipboard
class ServerError(val statusCode: Int, val body: ByteArray?, val retryAfterMillis: Long? = null) : NetworkError

A non-2xx status outside the specifically-mapped cases below, carrying the raw body and the parsed Retry-After hint in milliseconds (retryAfterMillis), when the server sent one.

Link copied to clipboard
data object Timeout : NetworkError

The request exceeded its timeout.

Link copied to clipboard

HTTP 401.

Link copied to clipboard

Any other transport-level failure.

Properties

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