Java
Errors
Handle Java API failures and inspect raw responses
Overview
This guide explains how to handle errors returned by the Insion SDK and inspect response details when troubleshooting failed requests.
Handle errors
API failures throw InsionClientApiException; other SDK failures extend InsionClientException.
import co.insion.core.InsionClientApiException;
try {
client.moderateARecord(request);
} catch (InsionClientApiException error) {
System.err.println(error.statusCode());
System.err.println(error.body());
throw error;
}Inspect raw responses
Use client.withRawResponse() when you need the HTTP wrapper. The returned InsionClientHttpResponse<T> exposes body() and headers().
InsionClientHttpResponse<ListRecordsResponse> response = client.withRawResponse().listRecords();
System.out.println(response.body().getHasMore());
System.out.println(response.headers());How is this guide?