Skip to content

Commit 4ddf6cb

Browse files
authored
Merge pull request #121 from Research-Institute/fix/#118
include inner exception messages in detail
2 parents 261e42e + c112f2b commit 4ddf6cb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/JsonApiDotNetCore/Internal/JsonApiExceptionFactory.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,19 @@ public static JsonApiException GetException(Exception exception)
1515
case "InvalidCastException":
1616
return new JsonApiException("409", exception.Message);
1717
default:
18-
return new JsonApiException("500", exception.Message);
18+
return new JsonApiException("500", exception.Message, GetExceptionDetail(exception.InnerException));
1919
}
2020
}
21+
22+
private static string GetExceptionDetail(Exception exception)
23+
{
24+
string detail = null;
25+
while(exception != null)
26+
{
27+
detail = $"{detail}{exception.Message}; ";
28+
exception = exception.InnerException;
29+
}
30+
return detail;
31+
}
2132
}
2233
}

0 commit comments

Comments
 (0)