Skip to content

Commit 2d5bc99

Browse files
author
Bart Koelman
committed
Fixed: stackTrace:null in output when options.IncludeExceptionStackTraceInErrors = false
1 parent 74f32f7 commit 2d5bc99

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/JsonApiDotNetCore/Models/JsonApiDocuments/ErrorMeta.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ public sealed class ErrorMeta
1515

1616
public void IncludeExceptionStackTrace(Exception exception)
1717
{
18-
Data["StackTrace"] = exception?.Demystify().ToString()
19-
.Split(new[] {"\n"}, int.MaxValue, StringSplitOptions.RemoveEmptyEntries);
18+
if (exception == null)
19+
{
20+
Data.Remove("StackTrace");
21+
}
22+
else
23+
{
24+
Data["StackTrace"] = exception.Demystify().ToString()
25+
.Split(new[] { "\n" }, int.MaxValue, StringSplitOptions.RemoveEmptyEntries);
26+
}
2027
}
2128
}
2229
}

0 commit comments

Comments
 (0)