standards-c-sharp

Only catch exceptions with good reason

Don’t

try
{
    return myService.GetData();
}
catch (Exception ex)
{
    Log.Error(ex.ToString()); 
    throw; // this will be caught by the global exception handler anyway, 
           // so we just end up logging the exception twice
}

Do

try
{
    return myService.GetData();
}
catch (MyServiceException ex)
{
    var betterEx = new MyApplicationException("Something bad happened with myService")
    {
         InnerException = ex,
         UserInfo = userInfo
    }
    throw betterEx; 
}