From c112f2b17622d4057040229b351489747a47fc78 Mon Sep 17 00:00:00 2001 From: jaredcnance Date: Wed, 31 May 2017 22:20:08 -0500 Subject: [PATCH] include inner exception messages in detail --- .../Internal/JsonApiExceptionFactory.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/JsonApiDotNetCore/Internal/JsonApiExceptionFactory.cs b/src/JsonApiDotNetCore/Internal/JsonApiExceptionFactory.cs index 41d676f5da..7e251ebae0 100644 --- a/src/JsonApiDotNetCore/Internal/JsonApiExceptionFactory.cs +++ b/src/JsonApiDotNetCore/Internal/JsonApiExceptionFactory.cs @@ -15,8 +15,19 @@ public static JsonApiException GetException(Exception exception) case "InvalidCastException": return new JsonApiException("409", exception.Message); default: - return new JsonApiException("500", exception.Message); + return new JsonApiException("500", exception.Message, GetExceptionDetail(exception.InnerException)); } } + + private static string GetExceptionDetail(Exception exception) + { + string detail = null; + while(exception != null) + { + detail = $"{detail}{exception.Message}; "; + exception = exception.InnerException; + } + return detail; + } } }