Skip to content

Commit

Permalink
Move request exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mibewh committed Jul 13, 2020
1 parent e10651d commit 0747331
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/CloudCMSDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,6 @@ public async Task<JObject> RequestAsync(string uri, HttpMethod method, IDictiona
{
HttpResponseMessage response = await _requestAsync(uri, method, queryParams, body);
string responseString = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
{
throw new CloudCMSRequestException(responseString);
}

return JObject.Parse(responseString);
}

Expand All @@ -208,6 +203,12 @@ private async Task<HttpResponseMessage> _requestAsync(string uri, HttpMethod met
client.DefaultRequestHeaders.Authorization = auth;

HttpResponseMessage response = await client.SendAsync(request);
if (!response.IsSuccessStatusCode)
{
string responseString = await response.Content.ReadAsStringAsync();
throw new CloudCMSRequestException(responseString);
}

return response;
}
}
Expand Down

0 comments on commit 0747331

Please sign in to comment.