diff --git a/Persistence.Client/Helpers/ExceptionsHelper.cs b/Persistence.Client/Helpers/ExceptionsHelper.cs index 8c349ba..0e3a31a 100644 --- a/Persistence.Client/Helpers/ExceptionsHelper.cs +++ b/Persistence.Client/Helpers/ExceptionsHelper.cs @@ -25,9 +25,11 @@ public static class ExceptionsHelper public static Exception GetPersistenceException(this IApiResponse response) { - var exception = ExceptionsDictionary - .FirstOrDefault(e => e.Key == response.StatusCode).Value ?? new Exception("Неопознанная ошибка"); + ExceptionsDictionary + .TryGetValue(response.StatusCode, out var exception); - return exception; + var result = exception ?? new Exception("Неопознанная ошибка"); + + return result; } }