Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed GetRawResponseContent to return content if there is some rega… #61

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/PortableRest/RestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,11 @@ private static async Task<T> GetResponseContent<T>([NotNull] RestRequest restReq
/// <returns></returns>
private static async Task<string> GetRawResponseContent([NotNull] HttpResponseMessage response)
{
//RWM: Explicitly check for NoContent... because the request was successful but there is nothing to do.
if (response.IsSuccessStatusCode && response.StatusCode != HttpStatusCode.NoContent)
//KW: If there's content I want to know what it is regardless of the wether the response has a success code
if (response.StatusCode != HttpStatusCode.NoContent)
{
return await response.Content.ReadAsStringAsync().ConfigureAwait(false);
string stringContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
return string.IsNullOrEmpty(stringContent) ? null : stringContent;
}
return null;
}
Expand Down Expand Up @@ -468,7 +469,10 @@ private static T DeserializeResponseContent<T>([NotNull] RestRequest restRequest
}
catch (JsonSerializationException jEx)
{
throw new PortableRestException("The JsonConverter failed. Please see InnerException for details.", jEx);
var prEx = new PortableRestException(
"The JsonConverter failed. Please see InnerException " +
$"for details. StatusCode {response.StatusCode} : ReasonPhrase {response.ReasonPhrase}", jEx);
throw prEx;
}
}

Expand Down