Skip to content

Commit

Permalink
#841 Завершил создание ошибок в рантайме
Browse files Browse the repository at this point in the history
  • Loading branch information
inyutin-maxim committed Aug 5, 2019
1 parent 97a7cf1 commit 64195cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 1 addition & 2 deletions VkNet/Utils/ExecuteErrorsHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public static AggregateException GetExecuteExceptions(string response)
ErrorMessage = exception.ErrorMessage,
Method = exception.Method,
RequestParams = exception.RequestParams
}))
.ToList();
}));

return new AggregateException(exceptionList);
}
Expand Down
11 changes: 9 additions & 2 deletions VkNet/Utils/VkErrors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,11 @@ private static Tuple<string, T> ThrowIfNumberIsNegative<T>(Expression<T> expr)
/// </exception>
public static void IfErrorThrowException(string json)
{
JObject obj;

try
{
JObject.Parse(json);
obj = JObject.Parse(json);
}
catch (JsonReaderException ex)
{
Expand All @@ -155,7 +157,12 @@ public static void IfErrorThrowException(string json)
throw exceptions;
}

var vkError = JsonConvert.DeserializeObject<VkError>(json);
if (!obj.TryGetValue("error", StringComparison.InvariantCulture, out var error))
{
return;
}

var vkError = JsonConvert.DeserializeObject<VkError>(error.ToString());

if (vkError == null || vkError.ErrorCode == 0)
{
Expand Down

0 comments on commit 64195cf

Please sign in to comment.