Error Handling - AquaticInformatics/aquarius-sdk-net GitHub Wiki

The Aquarius.Client.dll assembly 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 ErrorCode and ErrorMessage string properties 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
{
    using(client = AquariusClient.CreateConnectedClient("myserver", "myuser", "mypassword"))
    {
        var request = new LocationDescriptionListServiceRequest {LocationName = "My Location"};
        var response = client.Publish.Get(request);

        Console.WriteLine($"{response.LocationDescriptions.Count} matches found.");
    }
}
catch(WebServiceException exception)
{
    Console.WriteLine($"AQTS ERROR: {exception.ErrorCode} {exception.ErrorMessage}");
}
catch(Exception exception)
{
    Console.WriteLine($"ERROR: That was weird! {exception.Message} {exception.StackTrace}");
}