I have the following reoccurring try/catch pattern in my code. Using a try/catch block to handle any exceptions thrown when calling a method in orionProxy.
a
I don't see why it wouldn't work, assuming GetContacts
is an async
method:
public async Task<T> CheckForExceptionAsync<T>(Task<T> source)
{
try
{
return await source;
}
catch (Exception ex)
{
HandleException(ex);
return default(T);
}
}
On a side note, you should avoid async void (as I describe in my MSDN article) and end your async method names with the Async suffix.