Skip to content

Commit

Permalink
Handle ObjectDisposedException
Browse files Browse the repository at this point in the history
  • Loading branch information
mburumaxwell committed Jan 9, 2024
1 parent ef935f6 commit 53b3b99
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Tingle.Extensions.Http/ResourceResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,17 @@ protected HttpApiResponseException CreateException(string messagePrefix, bool ap
string serializeRequestHeaders() => serializeHeaders(new(Response.RequestMessage ?? new()));
string serializeResponseHeaders() => serializeHeaders(Headers);

static string serializeBody(HttpContent content) => content.ReadAsStringAsync().GetAwaiter().GetResult();
static string serializeBody(HttpContent content)
{
try
{
return content.ReadAsStringAsync().GetAwaiter().GetResult();
}
catch (ObjectDisposedException)
{
return "[disposed]";
}
}
string serializeRequestBody() => serializeBody((Response.RequestMessage ?? new()).Content ?? new StringContent(string.Empty));
string serializeResponseBody() => serializeBody(Response.Content);

Expand Down

0 comments on commit 53b3b99

Please sign in to comment.