Merged PR 6847: Merged PR 6846: Fix bug of exception catch.

Merged PR 6846: Fix bug of exception catch.

Modify exception catch.
This commit is contained in:
Siqi Liu 2019-01-22 10:20:08 +00:00
Родитель e012a3a285
Коммит 1a7b69a6c0
1 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -1811,15 +1811,15 @@ namespace Microsoft.ProjectOxford.Face
if (response.Content != null && response.Content.Headers.ContentType.MediaType.Contains(JsonContentTypeHeader))
{
var errorObjectString = await response.Content.ReadAsStringAsync();
ClientError ex = JsonConvert.DeserializeObject<ClientError>(errorObjectString);
if (ex.Error != null)
ClientError clientEx = JsonConvert.DeserializeObject<ClientError>(errorObjectString);
if (clientEx.Error != null)
{
throw new FaceAPIException(ex.Error.ErrorCode, ex.Error.Message, response.StatusCode);
throw new FaceAPIException(clientEx.Error.ErrorCode, clientEx.Error.Message, response.StatusCode);
}
else
{
ServiceError serviceEx = JsonConvert.DeserializeObject<ServiceError>(errorObjectString);
if (ex != null)
if (serviceEx.ErrorCode != null)
{
throw new FaceAPIException(serviceEx.ErrorCode, serviceEx.Message, response.StatusCode);
}