NetworkException

abstract class NetworkException : CronetException

kotlin.Any
   ↳ kotlin.Throwable
     ↳ java.lang.Exception
       ↳ java.io.IOException
         ↳ org.chromium.net.CronetException
           ↳ org.chromium.net.NetworkException
Known direct subclasses
QuicException

Subclass of NetworkException which contains a detailed QUIC error code from QuicErrorCode.


Exception passed to UrlRequest.Callback.onFailed() when Cronet fails to process a network request. In this case getErrorCode and getCronetInternalErrorCode can be used to get more information about the specific type of failure. If getErrorCode returns ERROR_QUIC_PROTOCOL_FAILED, this exception can be cast to a QuicException which can provide further details.

Summary

Constants

const Int

Error code indicating the IP address being contacted is unreachable, meaning there is no route to the specified host or network.

const Int

Error code indicating the connection was closed unexpectedly.

const Int

Error code indicating the connection attempt was refused.

const Int

Error code indicating the connection was unexpectedly reset.

const Int

Error code indicating the connection attempt timed out.

const Int

Error code indicating the host being sent the request could not be resolved to an IP address.

const Int

Error code indicating the device was not connected to any network.

const Int

Error code indicating that as the request was processed the network configuration changed.

const Int

Error code indicating another type of error was encountered.

const Int

Error code indicating an error related to the QUIC protocol.

const Int

Error code indicating a timeout expired.

Protected constructors

NetworkException(message: String!, cause: Throwable!)

Constructs an exception that is caused by a network error.

Public functions

abstract Int

Returns a Cronet internal error code.

abstract Int

Returns error code, one of ERROR_*.

abstract Boolean

Returns true if retrying this request right away might succeed, false otherwise.

Constants

ERROR_ADDRESS_UNREACHABLE

const val ERROR_ADDRESS_UNREACHABLE = 9: Int

Error code indicating the IP address being contacted is unreachable, meaning there is no route to the specified host or network.

ERROR_CONNECTION_CLOSED

const val ERROR_CONNECTION_CLOSED = 5: Int

Error code indicating the connection was closed unexpectedly.

ERROR_CONNECTION_REFUSED

const val ERROR_CONNECTION_REFUSED = 7: Int

Error code indicating the connection attempt was refused.

ERROR_CONNECTION_RESET

const val ERROR_CONNECTION_RESET = 8: Int

Error code indicating the connection was unexpectedly reset.

ERROR_CONNECTION_TIMED_OUT

const val ERROR_CONNECTION_TIMED_OUT = 6: Int

Error code indicating the connection attempt timed out.

ERROR_HOSTNAME_NOT_RESOLVED

const val ERROR_HOSTNAME_NOT_RESOLVED = 1: Int

Error code indicating the host being sent the request could not be resolved to an IP address.

ERROR_INTERNET_DISCONNECTED

const val ERROR_INTERNET_DISCONNECTED = 2: Int

Error code indicating the device was not connected to any network.

ERROR_NETWORK_CHANGED

const val ERROR_NETWORK_CHANGED = 3: Int

Error code indicating that as the request was processed the network configuration changed. When getErrorCode returns this code, this exception may be cast to QuicException for more information if QUIC protocol is used.

ERROR_OTHER

const val ERROR_OTHER = 11: Int

Error code indicating another type of error was encountered. getCronetInternalErrorCode can be consulted to get a more specific cause.

ERROR_QUIC_PROTOCOL_FAILED

const val ERROR_QUIC_PROTOCOL_FAILED = 10: Int

Error code indicating an error related to the QUIC protocol. When getErrorCode returns this code, this exception can be cast to QuicException for more information.

ERROR_TIMED_OUT

const val ERROR_TIMED_OUT = 4: Int

Error code indicating a timeout expired. Timeouts expiring while attempting to connect will be reported as the more specific ERROR_CONNECTION_TIMED_OUT.

Protected constructors

NetworkException

protected NetworkException(message: String!, cause: Throwable!)

Constructs an exception that is caused by a network error.

Parameters
message: String!

explanation of failure.

cause: Throwable!

the cause (which is saved for later retrieval by the getCause() method). A null value is permitted, and indicates that the cause is nonexistent or unknown.

Public functions

getCronetInternalErrorCode

abstract fun getCronetInternalErrorCode(): Int

Returns a Cronet internal error code. This may provide more specific error diagnosis than getErrorCode, but the constant values are not exposed to Java and may change over time. See here for the lastest list of values.

Returns
Int

Cronet internal error code.

getErrorCode

abstract fun getErrorCode(): Int

Returns error code, one of ERROR_*.

Returns
Int

error code, one of ERROR_*.

immediatelyRetryable

abstract fun immediatelyRetryable(): Boolean

Returns true if retrying this request right away might succeed, false otherwise. For example returns true when getErrorCode returns ERROR_NETWORK_CHANGED because trying the request might succeed using the new network configuration, but false when getErrorCode() returns ERROR_INTERNET_DISCONNECTED because retrying the request right away will encounter the same failure (instead retrying should be delayed until device regains network connectivity).

Returns
Boolean

true if retrying this request right away might succeed, false otherwise.