Skip to content

Commit d7a81d0

Browse files
author
Bart Koelman
committed
Removed exception for unable to serialize response
1 parent f0df15b commit d7a81d0

File tree

3 files changed

+3
-35
lines changed

3 files changed

+3
-35
lines changed

src/JsonApiDotNetCore/Exceptions/InvalidResponseBodyException.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/JsonApiDotNetCore/Formatters/JsonApiWriter.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using System.Net;
44
using System.Net.Http;
5-
using System.Reflection;
65
using System.Text;
76
using System.Threading.Tasks;
87
using JsonApiDotNetCore.Exceptions;
@@ -78,18 +77,7 @@ private string SerializeResponse(object contextObject, HttpStatusCode statusCode
7877

7978
contextObject = WrapErrors(contextObject);
8079

81-
try
82-
{
83-
return _serializer.Serialize(contextObject);
84-
}
85-
catch (TargetInvocationException exception)
86-
{
87-
throw new InvalidResponseBodyException(exception.InnerException);
88-
}
89-
catch (Exception exception)
90-
{
91-
throw new InvalidResponseBodyException(exception);
92-
}
80+
return _serializer.Serialize(contextObject);
9381
}
9482

9583
private static object WrapErrors(object contextObject)

test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/ThrowingResourceTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public async Task GetThrowingResource_Fails()
3333

3434
Assert.Single(errorDocument.Errors);
3535
Assert.Equal(HttpStatusCode.InternalServerError, errorDocument.Errors[0].StatusCode);
36-
Assert.Equal("Failed to serialize response body.", errorDocument.Errors[0].Title);
37-
Assert.Equal("The value for the 'FailsOnSerialize' property is currently unavailable.", errorDocument.Errors[0].Detail);
36+
Assert.Equal("An unhandled error occurred while processing this request.", errorDocument.Errors[0].Title);
37+
Assert.Equal("Exception has been thrown by the target of an invocation.", errorDocument.Errors[0].Detail);
3838

3939
var stackTraceLines =
4040
((JArray) errorDocument.Errors[0].Meta.Data["stackTrace"]).Select(token => token.Value<string>());

0 commit comments

Comments
 (0)