diff --git a/AsbCloudApp/Exceptions/ArgumentInvalidException.cs b/AsbCloudApp/Exceptions/ArgumentInvalidException.cs
index f5e3f3cd..5db63313 100644
--- a/AsbCloudApp/Exceptions/ArgumentInvalidException.cs
+++ b/AsbCloudApp/Exceptions/ArgumentInvalidException.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Linq;
namespace AsbCloudApp.Exceptions
{
@@ -9,9 +10,9 @@ namespace AsbCloudApp.Exceptions
public class ArgumentInvalidException : Exception
{
///
- /// название аргумента
+ /// словарь с ошибками, где ключ - имя аргумента, а значение - массив из одного сообщения
///
- public IDictionary ParamsNames { get; } = null!;
+ public IDictionary ErrorState { get; } = null!;
///
/// конструктор
@@ -21,7 +22,7 @@ namespace AsbCloudApp.Exceptions
public ArgumentInvalidException(string paramName, string message)
: base(message)
{
- ParamsNames = new Dictionary() {
+ ErrorState = new Dictionary() {
{ paramName, new[]{ message } }
};
}
@@ -34,9 +35,7 @@ namespace AsbCloudApp.Exceptions
public ArgumentInvalidException(string[] paramsNames, string message)
: base(message)
{
- ParamsNames = new Dictionary() {
- { string.Join(", ", paramsNames), new[]{ message } }
- };
+ ErrorState = paramsNames.ToDictionary(paramName => paramName, item => new[] { message });
}
}
}
diff --git a/AsbCloudWebApi/Middlewares/SimplifyExceptionsMiddleware.cs b/AsbCloudWebApi/Middlewares/SimplifyExceptionsMiddleware.cs
index 3b3f052a..3c444b4a 100644
--- a/AsbCloudWebApi/Middlewares/SimplifyExceptionsMiddleware.cs
+++ b/AsbCloudWebApi/Middlewares/SimplifyExceptionsMiddleware.cs
@@ -56,7 +56,7 @@ namespace AsbCloudWebApi.Middlewares
private static string MakeJsonBody(ArgumentInvalidException ex)
{
- var problem = new ValidationProblemDetails(ex.ParamsNames);
+ var problem = new ValidationProblemDetails(ex.ErrorState);
var buffer = System.Text.Json.JsonSerializer.Serialize(problem);
return buffer;
}