Skip to content

Instantly share code, notes, and snippets.

@diego-augusto
Last active September 4, 2018 22:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diego-augusto/17bf7f69d53364972fa7fb1b01622249 to your computer and use it in GitHub Desktop.
Save diego-augusto/17bf7f69d53364972fa7fb1b01622249 to your computer and use it in GitHub Desktop.
try
{
_unitOfWork.Commit();
}
catch (DbEntityValidationException e)
{
_logger.Error($"Exception: {e.Message}");
_logger.Error($"Inner: {e.InnerException?.Message}");
_logger.Error($"StackTrace: {e.StackTrace}");
foreach (var entity in e.EntityValidationErrors)
{
_logger.Error($"Entity: {entity.Entry.Entity.GetType().Name}");
foreach (var error in entity.ValidationErrors)
{
_logger.Error($"PropertyName: {error.PropertyName}");
_logger.Error($"ErrorMessage: {error.ErrorMessage}");
}
}
}
catch (Exception e)
{
_logger.Error($"Exception: {e.Message}");
_logger.Error($"Inner: {e.InnerException?.Message}");
_logger.Error($"StackTrace: {e.StackTrace}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment