Update: DbEntityValidationException Detailed Logs

This commit is contained in:
Gary Sharp
2013-05-13 13:28:25 +10:00
parent 4481909866
commit 05a4907b2c
7 changed files with 35 additions and 15 deletions
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0509.1618")]
[assembly: AssemblyFileVersion("1.2.0509.1618")]
[assembly: AssemblyVersion("1.2.0513.1327")]
[assembly: AssemblyFileVersion("1.2.0513.1327")]
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0509.1622")]
[assembly: AssemblyFileVersion("1.2.0509.1622")]
[assembly: AssemblyVersion("1.2.0513.1327")]
[assembly: AssemblyFileVersion("1.2.0513.1327")]
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0509.1622")]
[assembly: AssemblyFileVersion("1.2.0509.1622")]
[assembly: AssemblyVersion("1.2.0513.1327")]
[assembly: AssemblyFileVersion("1.2.0513.1327")]
+23 -3
View File
@@ -44,13 +44,33 @@ namespace Disco.Services.Logging
}
public static void LogException(string Component, Exception ex)
{
if (ex.InnerException != null)
// Handle Special-Case Errors
if (ex is System.Data.Entity.Validation.DbEntityValidationException)
{
Log(EventTypeIds.ExceptionWithInner, Component, ex.GetType().Name, ex.Message, ex.StackTrace, ex.InnerException.GetType().Name, ex.InnerException.Message, ex.InnerException.StackTrace);
var dbException = (System.Data.Entity.Validation.DbEntityValidationException)ex;
StringBuilder message = new StringBuilder();
message.AppendLine("Validation failed for one or more entities:");
foreach (var dbEntityError in dbException.EntityValidationErrors)
{
message.Append("'").Append(dbEntityError.Entry.Entity.GetType().Name).AppendLine("' Object");
foreach (var dbValidationError in dbEntityError.ValidationErrors)
{
message.Append(" ").Append(dbValidationError.PropertyName).Append(": ").AppendLine(dbValidationError.ErrorMessage);
}
}
Log(EventTypeIds.Exception, Component, ex.GetType().Name, message.ToString(), ex.StackTrace);
}
else
{
Log(EventTypeIds.Exception, Component, ex.GetType().Name, ex.Message, ex.StackTrace);
if (ex.InnerException != null)
{
Log(EventTypeIds.ExceptionWithInner, Component, ex.GetType().Name, ex.Message, ex.StackTrace, ex.InnerException.GetType().Name, ex.InnerException.Message, ex.InnerException.StackTrace);
}
else
{
Log(EventTypeIds.Exception, Component, ex.GetType().Name, ex.Message, ex.StackTrace);
}
}
}
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0509.1622")]
[assembly: AssemblyFileVersion("1.2.0509.1622")]
[assembly: AssemblyVersion("1.2.0513.1327")]
[assembly: AssemblyFileVersion("1.2.0513.1327")]
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0509.1622")]
[assembly: AssemblyFileVersion("1.2.0509.1622")]
[assembly: AssemblyVersion("1.2.0513.1327")]
[assembly: AssemblyFileVersion("1.2.0513.1327")]
+2 -2
View File
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.2.0509.1622")]
[assembly: AssemblyFileVersion("1.2.0509.1622")]
[assembly: AssemblyVersion("1.2.0513.1327")]
[assembly: AssemblyFileVersion("1.2.0513.1327")]