Class InterledgerClientException
java.lang.Object
java.lang.Throwable
java.lang.Exception
io.fliqa.client.interledger.exception.InterledgerClientException
- All Implemented Interfaces:
Serializable
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 Summary
ConstructorsConstructorDescriptionInterledgerClientException(int code, String message) Constructs a new InterledgerClientException with an HTTP status code and error message.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.InterledgerClientException(int code, HttpHeaders responseHeaders, String responseBody) Constructs a new InterledgerClientException with the specified HTTP status code, response headers, and response body.InterledgerClientException(String message) Creates a new exception with a descriptive message.InterledgerClientException(String message, int code, HttpHeaders responseHeaders, String responseBody) Creates a new exception with HTTP response details.InterledgerClientException(String message, Throwable throwable, int code, HttpHeaders responseHeaders) Constructs a new InterledgerClientException with full HTTP response details and an underlying cause.InterledgerClientException(String message, Throwable throwable, int code, HttpHeaders responseHeaders, String responseBody) Creates a new exception with full HTTP response details and an underlying cause.InterledgerClientException(Throwable throwable) Creates a new exception wrapping an underlying cause. -
Method Summary
Modifier and TypeMethodDescriptionstatic InterledgerClientExceptiongetApiException(ApiError error, HttpResponse<String> response) Creates an exception from an Interledger API error response.intgetCode()Get the HTTP status code.Get the HTTP response body.Get the HTTP response headers.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
InterledgerClientException
Creates a new exception wrapping an underlying cause.- Parameters:
throwable- the underlying cause of this exception
-
InterledgerClientException
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 messagethrowable- the underlying causecode- the HTTP status coderesponseHeaders- the HTTP response headersresponseBody- 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 messagecode- the HTTP status coderesponseHeaders- the HTTP response headersresponseBody- 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 exceptionthrowable- the underlying cause of this exceptioncode- the HTTP status code associated with this exceptionresponseHeaders- the HTTP response headers returned by the server
-
InterledgerClientException
Constructs a new InterledgerClientException with the specified HTTP status code, response headers, and response body.- Parameters:
code- the HTTP status coderesponseHeaders- the HTTP response headersresponseBody- the HTTP response body
-
InterledgerClientException
Constructs a new InterledgerClientException with an HTTP status code and error message.- Parameters:
code- the HTTP status code associated with this exceptionmessage- 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 exceptionmessage- the error message describing the exceptionresponseHeaders- the HTTP response headers returned by the serverresponseBody- the HTTP response body as a string
-
-
Method Details
-
getCode
public int getCode()Get the HTTP status code.- Returns:
- HTTP status code
-
getResponseHeaders
Get the HTTP response headers.- Returns:
- Headers as an HttpHeaders object
-
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 bodyresponse- the HTTP response containing error details- Returns:
- a new exception with formatted error message and response details
-