Class NetworkException

All Implemented Interfaces:
Serializable

public class NetworkException extends TransportException
Exception for network connectivity issues such as DNS failures, connection refused, or general I/O errors during HTTP communication.

This exception inherits request context from TransportException:

Example usage:


 try {
     client.customers().list();
 } catch (NetworkException e) {
     System.err.println("Failed to connect to: " + e.getUrl());
     System.err.println("Method: " + e.getHttpMethod());
     System.err.println("Cause: " + e.getCause().getMessage());
     
     if (e.isRetryable()) {
         // Implement retry logic
     }
 }
 
See Also:
  • Constructor Details

    • NetworkException

      public NetworkException(String message, Throwable cause, Request request)
      Creates a NetworkException with request context.
      Parameters:
      message - descriptive error message
      cause - the underlying cause (e.g., IOException)
      request - the HTTP request that failed
    • NetworkException

      public NetworkException(String message, Throwable cause)
      Creates a NetworkException without request context. Prefer NetworkException(String, Throwable, Request) when request is available.
      Parameters:
      message - descriptive error message
      cause - the underlying cause
  • Method Details

    • isRetryable

      public boolean isRetryable()
      Network errors are generally retryable as they may be transient (e.g., temporary DNS issues, network hiccups).
      Overrides:
      isRetryable in class TransportException
      Returns:
      true, indicating this error is typically retryable