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:
Родитель
e012a3a285
Коммит
1a7b69a6c0
|
@ -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);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче