public abstract class**NetworkException** extends[CronetException](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetException.html)  

|---|---|---|
| Known Direct Subclasses [QuicException](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/QuicException.html) |--------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [QuicException](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/QuicException.html) | Subclass of[NetworkException](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html)which contains a detailed[QUIC](https://www.chromium.org/quic)error code from[QuicErrorCode](https://cs.chromium.org/search/?q=symbol:%5CbQuicErrorCode%5Cb). | |||

Exception passed to[UrlRequest.Callback.onFailed()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html#onFailed(org.chromium.net.UrlRequest,%20org.chromium.net.UrlResponseInfo,%20org.chromium.net.CronetException))when Cronet fails to process a network request. In this case[getErrorCode()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#getErrorCode())and[getCronetInternalErrorCode()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#getCronetInternalErrorCode())can be used to get more information about the specific type of failure. If[getErrorCode()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#getErrorCode())returns[ERROR_QUIC_PROTOCOL_FAILED](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#ERROR_QUIC_PROTOCOL_FAILED), this exception can be cast to a[QuicException](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/QuicException.html)which can provide further details.  

### Constant Summary

|-----|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
| int | [ERROR_ADDRESS_UNREACHABLE](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#ERROR_ADDRESS_UNREACHABLE)     | Error code indicating the IP address being contacted is unreachable, meaning there is no route to the specified host or network. |
| int | [ERROR_CONNECTION_CLOSED](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#ERROR_CONNECTION_CLOSED)         | Error code indicating the connection was closed unexpectedly.                                                                    |
| int | [ERROR_CONNECTION_REFUSED](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#ERROR_CONNECTION_REFUSED)       | Error code indicating the connection attempt was refused.                                                                        |
| int | [ERROR_CONNECTION_RESET](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#ERROR_CONNECTION_RESET)           | Error code indicating the connection was unexpectedly reset.                                                                     |
| int | [ERROR_CONNECTION_TIMED_OUT](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#ERROR_CONNECTION_TIMED_OUT)   | Error code indicating the connection attempt timed out.                                                                          |
| int | [ERROR_HOSTNAME_NOT_RESOLVED](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#ERROR_HOSTNAME_NOT_RESOLVED) | Error code indicating the host being sent the request could not be resolved to an IP address.                                    |
| int | [ERROR_INTERNET_DISCONNECTED](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#ERROR_INTERNET_DISCONNECTED) | Error code indicating the device was not connected to any network.                                                               |
| int | [ERROR_NETWORK_CHANGED](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#ERROR_NETWORK_CHANGED)             | Error code indicating that as the request was processed the network configuration changed.                                       |
| int | [ERROR_OTHER](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#ERROR_OTHER)                                 | Error code indicating another type of error was encountered.                                                                     |
| int | [ERROR_QUIC_PROTOCOL_FAILED](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#ERROR_QUIC_PROTOCOL_FAILED)   | Error code indicating an error related to the[QUIC](https://www.chromium.org/quic)protocol.                                      |
| int | [ERROR_TIMED_OUT](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#ERROR_TIMED_OUT)                         | Error code indicating a timeout expired.                                                                                         |

### Protected Constructor Summary

|---|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|   | [NetworkException](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#NetworkException(java.lang.String,%20java.lang.Throwable))(String message, Throwable cause) Constructs an exception that is caused by a network error. |

### Public Method Summary

|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| abstract int     | [getCronetInternalErrorCode](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#getCronetInternalErrorCode())() Returns a Cronet internal error code.                                                                                                            |
| abstract int     | [getErrorCode](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#getErrorCode())() Returns error code, one of[ERROR_*](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#ERROR_HOSTNAME_NOT_RESOLVED). |
| abstract boolean | [immediatelyRetryable](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#immediatelyRetryable())() Returns`true`if retrying this request right away might succeed,`false`otherwise.                                                                             |

### Inherited Method Summary

From class java.lang.Throwable  

|----------------------------------|-------------------------------------------|
| synchronized final void          | addSuppressed(Throwable arg0)             |
| synchronized Throwable           | fillInStackTrace()                        |
| synchronized Throwable           | getCause()                                |
| String                           | getLocalizedMessage()                     |
| String                           | getMessage()                              |
| StackTraceElement\[\]            | getStackTrace()                           |
| synchronized final Throwable\[\] | getSuppressed()                           |
| synchronized Throwable           | initCause(Throwable arg0)                 |
| void                             | printStackTrace()                         |
| void                             | printStackTrace(PrintWriter arg0)         |
| void                             | printStackTrace(PrintStream arg0)         |
| void                             | setStackTrace(StackTraceElement\[\] arg0) |
| String                           | toString()                                |

From class java.lang.Object  

|------------------|---------------------------|
| Object           | clone()                   |
| boolean          | equals(Object arg0)       |
| void             | finalize()                |
| final Class\<?\> | getClass()                |
| int              | hashCode()                |
| final void       | notify()                  |
| final void       | notifyAll()               |
| String           | toString()                |
| final void       | wait(long arg0, int arg1) |
| final void       | wait(long arg0)           |
| final void       | wait()                    |

## Constants

#### public static final int**ERROR_ADDRESS_UNREACHABLE**

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

#### public static final int**ERROR_CONNECTION_CLOSED**

Error code indicating the connection was closed unexpectedly.  
Constant Value:5  

#### public static final int**ERROR_CONNECTION_REFUSED**

Error code indicating the connection attempt was refused.  
Constant Value:7  

#### public static final int**ERROR_CONNECTION_RESET**

Error code indicating the connection was unexpectedly reset.  
Constant Value:8  

#### public static final int**ERROR_CONNECTION_TIMED_OUT**

Error code indicating the connection attempt timed out.  
Constant Value:6  

#### public static final int**ERROR_HOSTNAME_NOT_RESOLVED**

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

#### public static final int**ERROR_INTERNET_DISCONNECTED**

Error code indicating the device was not connected to any network.  
Constant Value:2  

#### public static final int**ERROR_NETWORK_CHANGED**

Error code indicating that as the request was processed the network configuration changed. When[getErrorCode()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#getErrorCode())returns this code, this exception may be cast to[QuicException](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/QuicException.html)for more information if[QUIC](https://www.chromium.org/quic)protocol is used.  
Constant Value:3  

#### public static final int**ERROR_OTHER**

Error code indicating another type of error was encountered.[getCronetInternalErrorCode()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#getCronetInternalErrorCode())can be consulted to get a more specific cause.  
Constant Value:11  

#### public static final int**ERROR_QUIC_PROTOCOL_FAILED**

Error code indicating an error related to the[QUIC](https://www.chromium.org/quic)protocol. When[getErrorCode()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#getErrorCode())returns this code, this exception can be cast to[QuicException](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/QuicException.html)for more information.  
Constant Value:10  

#### public static final int**ERROR_TIMED_OUT**

Error code indicating a timeout expired. Timeouts expiring while attempting to connect will be reported as the more specific[ERROR_CONNECTION_TIMED_OUT](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#ERROR_CONNECTION_TIMED_OUT).  
Constant Value:4

## Protected Constructors

#### protected**NetworkException**(String message, Throwable cause)

Constructs an exception that is caused by a network error.  

##### Parameters

| message |                                                                                                                       explanation of failure.                                                                                                                        |
|  cause  | the cause (which is saved for later retrieval by the[getCause()](https://developer.android.com/develop/connectivity/cronet/reference/java/lang/Throwable.html#getCause())method). A null value is permitted, and indicates that the cause is nonexistent or unknown. |
|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|

## Public Methods

#### public abstract int**getCronetInternalErrorCode**()

Returns a Cronet internal error code. This may provide more specific error diagnosis than[getErrorCode()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#getErrorCode()), but the constant values are not exposed to Java and may change over time. See[here](https://chromium.googlesource.com/chromium/src/+/main/net/base/net_error_list.h)for the latest list of values.  

##### Returns

- Cronet internal error code.  

#### public abstract int**getErrorCode**()

Returns error code, one of[ERROR_*](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#ERROR_HOSTNAME_NOT_RESOLVED).  

##### Returns

- error code, one of[ERROR_*](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#ERROR_HOSTNAME_NOT_RESOLVED).  

#### public abstract boolean**immediatelyRetryable**()

Returns`true`if retrying this request right away might succeed,`false`otherwise. For example returns`true`when[getErrorCode()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#getErrorCode())returns[ERROR_NETWORK_CHANGED](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#ERROR_NETWORK_CHANGED)because trying the request might succeed using the new network configuration, but`false`when`getErrorCode()`returns[ERROR_INTERNET_DISCONNECTED](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkException.html#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

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