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) {