Skip to content

Commit

Permalink
Captured the JSONException that may occur on a Non-Success StatusCode…
Browse files Browse the repository at this point in the history
… when attempting to Deserialize the HTTPResponse.Content when it is not JSON
  • Loading branch information
John-Hart committed Apr 14, 2016
1 parent 97545e3 commit 8b015ac
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,16 @@ public static class AzureClientExtensions
statusCode != HttpStatusCode.Created &&
statusCode != HttpStatusCode.NoContent)
{
CloudError errorBody = SafeJsonConvert.DeserializeObject<CloudError>(responseContent, client.DeserializationSettings);
CloudError errorBody = null;
try
{
errorBody = SafeJsonConvert.DeserializeObject<CloudError>(responseContent, client.DeserializationSettings);
}
catch (JsonException)
{
// failed to deserialize, return empty body
}

throw new CloudException(string.Format(CultureInfo.InvariantCulture,
Resources.LongRunningOperationFailed, statusCode))
{
Expand Down

0 comments on commit 8b015ac

Please sign in to comment.