Last active
August 29, 2015 14:06
-
-
Save MiniverCheevy/8af032691b8afa26a49b to your computer and use it in GitHub Desktop.
DbEntityValidationExceptionTranlator
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
public class DbEntityValidationExceptionTranlator: ExceptionTranslation | |
{ | |
protected override bool TranslateException(Exception exception, IResponse response) | |
{ | |
var dbException = exception as DbEntityValidationException; | |
if (dbException == null) | |
return false; | |
response.Message = dbException.Message; | |
foreach (var item in dbException.EntityValidationErrors) | |
{ | |
foreach (var error in item.ValidationErrors) | |
{ | |
response.Details.Add(error.PropertyName, error.ErrorMessage); | |
} | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment