Skip to content

Error Handling

Doug Schmidt edited this page Sep 15, 2017 · 1 revision

The com.aquaticinformatics:aquarius.sdk package uses the standard ServiceStack error-handling approach, throwing a WebServiceException whenever a request does not complete successfully (with a 2xx HTTP status code).

Usually, the getErrorCode() and getErrorMessage() methods of the WebServiceException object are all that need to be inspected to diagnose what went wrong. Other properties (like the HTTP status code and response headers) are available on the WebServiceException class if more detailed analysis is required.

try (AquariusClient client = AquariusClient.createConnectedClient("myserver", "myuser", "mypassword")) {
        var request = new LocationDescriptionListServiceRequest {LocationName = "My Location"};
        var response = client.PublishClient.Get();

        Console.WriteLine($"{response.LocationDescriptions.Count} matches found.");
} catch (WebServiceException e) {
    System.out.format("AQTS ERROR: "ERROR: %d (%s) %s\n", e.getStatusCode(), e.getErrorCode(), e.getErrorMessage());
} catch (Exception e) {
    System.out.format("ERROR: That was weird! %s", e.getMessage());
    e.printStackTrace();
}

Clone this wiki locally