From 64195cf4eaeaeb2e986a51828365a94ccebccf4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=BD=D1=8E=D1=82=D0=B8=D0=BD=20=D0=9C=D0=B0=D0=BA?= =?UTF-8?q?=D1=81=D0=B8=D0=BC=20=D0=9D=D0=B8=D0=BA=D0=BE=D0=BB=D0=B0=D0=B5?= =?UTF-8?q?=D0=B2=D0=B8=D1=87?= Date: Tue, 6 Aug 2019 01:30:17 +0300 Subject: [PATCH] =?UTF-8?q?#841=20=D0=97=D0=B0=D0=B2=D0=B5=D1=80=D1=88?= =?UTF-8?q?=D0=B8=D0=BB=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA=20=D0=B2=20=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D1=82=D0=B0=D0=B9=D0=BC=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VkNet/Utils/ExecuteErrorsHandler.cs | 3 +-- VkNet/Utils/VkErrors.cs | 11 +++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/VkNet/Utils/ExecuteErrorsHandler.cs b/VkNet/Utils/ExecuteErrorsHandler.cs index c0d9fc8c7..310202008 100644 --- a/VkNet/Utils/ExecuteErrorsHandler.cs +++ b/VkNet/Utils/ExecuteErrorsHandler.cs @@ -37,8 +37,7 @@ public static AggregateException GetExecuteExceptions(string response) ErrorMessage = exception.ErrorMessage, Method = exception.Method, RequestParams = exception.RequestParams - })) - .ToList(); + })); return new AggregateException(exceptionList); } diff --git a/VkNet/Utils/VkErrors.cs b/VkNet/Utils/VkErrors.cs index 5f01eafc8..57d4f359d 100644 --- a/VkNet/Utils/VkErrors.cs +++ b/VkNet/Utils/VkErrors.cs @@ -139,9 +139,11 @@ private static Tuple ThrowIfNumberIsNegative(Expression expr) /// public static void IfErrorThrowException(string json) { + JObject obj; + try { - JObject.Parse(json); + obj = JObject.Parse(json); } catch (JsonReaderException ex) { @@ -155,7 +157,12 @@ public static void IfErrorThrowException(string json) throw exceptions; } - var vkError = JsonConvert.DeserializeObject(json); + if (!obj.TryGetValue("error", StringComparison.InvariantCulture, out var error)) + { + return; + } + + var vkError = JsonConvert.DeserializeObject(error.ToString()); if (vkError == null || vkError.ErrorCode == 0) {