Created
July 30, 2013 23:22
-
-
Save danielmackay/6117945 to your computer and use it in GitHub Desktop.
Wrap function. Good way to have a generic exception handler.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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