I'd like to get a list of all the Azure Table errors and figure out a clean way to handle them in a try...catch
block.
For example, I'd like to not have to directly code and compare the InnerException message to String.Contains("The specified entity already exists")
. What is the right way to trap these errors?
You could try looking at the values in the Response, rather that the inner exception. This is an example of one of my try catch blocks:
try {
return query.FirstOrDefault();
}
catch (System.Data.Services.Client.DataServiceQueryException ex)
{
if (ex.Response.StatusCode == (int)System.Net.HttpStatusCode.NotFound) {
return null;
}
throw;
}
Obviously this is just for the item doesn't exist error, but I'm sure you can expand on this concept by looking at the list of Azure error codes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With