Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/JsonApiDotNetCore/Errors/InvalidModelStateException.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Reflection;
Expand Down Expand Up @@ -80,7 +81,7 @@ private static Error FromModelError(ModelError modelError, string attributeName,

if (includeExceptionStackTraceInErrors && modelError.Exception != null)
{
error.Meta.IncludeExceptionStackTrace(modelError.Exception);
error.Meta.IncludeExceptionStackTrace(modelError.Exception.Demystify());
}

return error;
Expand Down
4 changes: 3 additions & 1 deletion src/JsonApiDotNetCore/Middleware/ExceptionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ protected virtual ErrorDocument CreateErrorDocument(Exception exception)

private void ApplyOptions(Error error, Exception exception)
{
error.Meta.IncludeExceptionStackTrace(_options.IncludeExceptionStackTraceInErrors ? exception : null);
Exception resultException = exception is InvalidModelStateException ? null : exception;

error.Meta.IncludeExceptionStackTrace(_options.IncludeExceptionStackTraceInErrors ? resultException : null);
}
}
}
3 changes: 1 addition & 2 deletions src/JsonApiDotNetCore/Serialization/Objects/ErrorMeta.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Newtonsoft.Json;

namespace JsonApiDotNetCore.Serialization.Objects
Expand All @@ -21,7 +20,7 @@ public void IncludeExceptionStackTrace(Exception exception)
}
else
{
Data["StackTrace"] = exception.Demystify().ToString()
Data["StackTrace"] = exception.ToString()
.Split("\n", int.MaxValue, StringSplitOptions.RemoveEmptyEntries);
}
}
Expand Down