Class TimeoutException

All Implemented Interfaces:
Serializable

public class TimeoutException extends TransportException
Exception for connection or read timeouts during HTTP communication.

This exception inherits request context from TransportException and adds:

Inherited from base class:

Example usage:


 try {
     client.customers().list();
 } catch (TimeoutException e) {
     System.err.println("Timeout type: " + e.getTimeoutType());
     System.err.println("Failed URL: " + e.getUrl());
     
     if (e.isConnectTimeout()) {
         // Server might be down or unreachable
     } else if (e.isReadTimeout()) {
         // Server is slow to respond, consider increasing timeout
     }
     
     if (e.isRetryable()) {
         // Implement retry logic
     }
 }
 
See Also:
  • Field Details

  • Constructor Details

    • TimeoutException

      public TimeoutException(String timeoutType, String message, Throwable cause, Request request)
      Creates a TimeoutException with request context.
      Parameters:
      timeoutType - the type of timeout ("connect" or "read")
      message - descriptive error message
      cause - the underlying cause
      request - the HTTP request that timed out
    • TimeoutException

      public TimeoutException(String timeoutType, String message, Throwable cause)
      Creates a TimeoutException without request context. Prefer TimeoutException(String, String, Throwable, Request) when request is available.
      Parameters:
      timeoutType - the type of timeout ("connect" or "read")
      message - descriptive error message
      cause - the underlying cause
  • Method Details

    • getTimeoutType

      public String getTimeoutType()
      Get the type of timeout that occurred.
      Returns:
      "connect" for connection timeouts, "read" for read timeouts
    • isConnectTimeout

      public boolean isConnectTimeout()
      Check if this was a connection timeout. Connection timeouts occur when the server cannot be reached within the connect timeout period.
      Returns:
      true if this is a connection timeout
    • isReadTimeout

      public boolean isReadTimeout()
      Check if this was a read timeout. Read timeouts occur when the server doesn't respond within the read timeout period.
      Returns:
      true if this is a read timeout
    • isRetryable

      public boolean isRetryable()
      Timeouts are generally retryable as they may be transient (e.g., temporary server load, network congestion).
      Overrides:
      isRetryable in class TransportException
      Returns:
      true, indicating this error is typically retryable
    • toString

      public String toString()
      Overrides:
      toString in class TransportException