AQSamples Error Handling - AquaticInformatics/aquarius-sdk-net GitHub Wiki
The Aquarius.Client.dll
assembly uses the standard ServiceStack error-handling approach, throwing a SamplesApiException
whenever a request does not complete successfully (with a 2xx HTTP status code).
Usually, the StatusCode
integer property and optional SamplesError?.ErrorCode
string property 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 SamplesApiException
class if more detailed analysis is required.
try
{
var client = SamplesClient.CreateConnectedClient("https://myorg.aqsamples.com", "01234567890123456789012345678901");
var project = client.Get(new GetProject{ Id = "1234" });
}
catch (SamplesException exception)
{
Console.WriteLine($"AQS ERROR: {exception.StatusCode} - {exception.SamplesError?.ErrorCode}: {exception.SamplesError?.Message}");
}
catch (Exception exception)
{
Console.WriteLine($"ERROR: That was weird! {exception.Message} {exception.StackTrace}");
}