Skip to content

Instantly share code, notes, and snippets.

@danielmackay
Created July 30, 2013 23:22
Show Gist options
  • Save danielmackay/6117945 to your computer and use it in GitHub Desktop.
Save danielmackay/6117945 to your computer and use it in GitHub Desktop.
Wrap function. Good way to have a generic exception handler.
private static void Wrap(Action func)
{
try
{
func();
}
catch (DbEntityValidationException ex)
{
var error = ex.EntityValidationErrors.First().ValidationErrors.First();
Debug.WriteLine(error.PropertyName + ": " + error.ErrorMessage);
throw;
}
catch (Exception ex)
{
Debug.WriteLine("Error: " + ex);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment