From 1a7b69a6c07f60789a70222891250f9dd5c9b171 Mon Sep 17 00:00:00 2001 From: Siqi Liu Date: Tue, 22 Jan 2019 10:20:08 +0000 Subject: [PATCH] Merged PR 6847: Merged PR 6846: Fix bug of exception catch. Merged PR 6846: Fix bug of exception catch. Modify exception catch. --- ClientLibrary/FaceServiceClient.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ClientLibrary/FaceServiceClient.cs b/ClientLibrary/FaceServiceClient.cs index 63e8041..a9b1a5e 100644 --- a/ClientLibrary/FaceServiceClient.cs +++ b/ClientLibrary/FaceServiceClient.cs @@ -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(errorObjectString); - if (ex.Error != null) + ClientError clientEx = JsonConvert.DeserializeObject(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(errorObjectString); - if (ex != null) + if (serviceEx.ErrorCode != null) { throw new FaceAPIException(serviceEx.ErrorCode, serviceEx.Message, response.StatusCode); }