Class InterledgerClientException

java.lang.Object
java.lang.Throwable
java.lang.Exception
io.fliqa.client.interledger.exception.InterledgerClientException
All Implemented Interfaces:
Serializable

public class InterledgerClientException extends Exception
Exception thrown when errors occur during Interledger API operations.

This exception encapsulates both network-level errors (timeouts, connection failures) and application-level errors (invalid requests, authentication failures, server errors). It provides access to HTTP status codes, response headers, and response bodies when available to help with debugging and error handling.

Error Categories

  • Network Errors - Connection timeouts, DNS failures, network unreachable
  • Client Errors (4xx) - Invalid requests, authentication failures, not found
  • Server Errors (5xx) - Interledger server internal errors, service unavailable

Usage

When catching this exception, applications can inspect the HTTP status code to determine the appropriate response:


 try {
     PaymentPointer wallet = client.getWallet(address);
 } catch (InterledgerClientException e) {
     if (e.getCode() == 404) {
         // Wallet not found
     } else if (e.getCode() >= 500) {
         // Server error - retry may be appropriate
     }
 }
 
Since:
1.0
See Also:
  • Constructor Details

    • InterledgerClientException

      public InterledgerClientException(Throwable throwable)
      Creates a new exception wrapping an underlying cause.
      Parameters:
      throwable - the underlying cause of this exception
    • InterledgerClientException

      public InterledgerClientException(String message)
      Creates a new exception with a descriptive message.
      Parameters:
      message - the error message describing what went wrong
    • InterledgerClientException

      public InterledgerClientException(String message, Throwable throwable, int code, HttpHeaders responseHeaders, String responseBody)
      Creates a new exception with full HTTP response details and an underlying cause.
      Parameters:
      message - the error message
      throwable - the underlying cause
      code - the HTTP status code
      responseHeaders - the HTTP response headers
      responseBody - the HTTP response body
    • InterledgerClientException

      public InterledgerClientException(String message, int code, HttpHeaders responseHeaders, String responseBody)
      Creates a new exception with HTTP response details.
      Parameters:
      message - the error message
      code - the HTTP status code
      responseHeaders - the HTTP response headers
      responseBody - the HTTP response body
    • InterledgerClientException

      public InterledgerClientException(String message, Throwable throwable, int code, HttpHeaders responseHeaders)
      Constructs a new InterledgerClientException with full HTTP response details and an underlying cause.
      Parameters:
      message - the error message associated with this exception
      throwable - the underlying cause of this exception
      code - the HTTP status code associated with this exception
      responseHeaders - the HTTP response headers returned by the server
    • InterledgerClientException

      public InterledgerClientException(int code, HttpHeaders responseHeaders, String responseBody)
      Constructs a new InterledgerClientException with the specified HTTP status code, response headers, and response body.
      Parameters:
      code - the HTTP status code
      responseHeaders - the HTTP response headers
      responseBody - the HTTP response body
    • InterledgerClientException

      public InterledgerClientException(int code, String message)
      Constructs a new InterledgerClientException with an HTTP status code and error message.
      Parameters:
      code - the HTTP status code associated with this exception
      message - the error message describing the exception
    • InterledgerClientException

      public InterledgerClientException(int code, String message, HttpHeaders responseHeaders, String responseBody)
      Constructs a new InterledgerClientException with an HTTP status code, error message, response headers, and response body.
      Parameters:
      code - the HTTP status code associated with this exception
      message - the error message describing the exception
      responseHeaders - the HTTP response headers returned by the server
      responseBody - the HTTP response body as a string
  • Method Details

    • getCode

      public int getCode()
      Get the HTTP status code.
      Returns:
      HTTP status code
    • getResponseHeaders

      public HttpHeaders getResponseHeaders()
      Get the HTTP response headers.
      Returns:
      Headers as an HttpHeaders object
    • getResponseBody

      public String getResponseBody()
      Get the HTTP response body.
      Returns:
      Response body in the form of string
    • getApiException

      public static InterledgerClientException getApiException(ApiError error, HttpResponse<String> response)
      Creates an exception from an Interledger API error response.

      This factory method constructs a properly formatted exception from an API error response, including the HTTP status code, headers, and structured error information.

      Parameters:
      error - the parsed API error from the response body
      response - the HTTP response containing error details
      Returns:
      a new exception with formatted error message and response details