Interfaccia, parte 2: Attività, Impostazioni, collegamento, Importa, doppioni, primo avvio ed errori di configurazione
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mzbb6zeFTjT6Rp8b92AVkA
This commit is contained in:
90 files changed
+7825
-49
No files matched your search
@@ -34,7 +34,7 @@ public sealed class ApiErrorMiddleware(RequestDelegate next, ILogger<ApiErrorMid
|
||||
var (status, message) = ex switch
|
||||
{
|
||||
BadRequestException => (StatusCodes.Status400BadRequest, ex.Message),
|
||||
ArgumentException => (StatusCodes.Status400BadRequest, ex.Message),
|
||||
ArgumentException a => (StatusCodes.Status400BadRequest, CleanMessage(a)),
|
||||
JsonException => (StatusCodes.Status400BadRequest, "Richiesta non leggibile."),
|
||||
BadHttpRequestException => (StatusCodes.Status400BadRequest, "Richiesta non leggibile."),
|
||||
NotFoundException => (StatusCodes.Status404NotFound, ex.Message),
|
||||
@@ -53,6 +53,13 @@ public sealed class ApiErrorMiddleware(RequestDelegate next, ILogger<ApiErrorMid
|
||||
await context.Response.WriteAsJsonAsync(new ProblemDto(message), FebeJsonContext.Default.ProblemDto).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The Italian message of an argument error, without the « (Parameter 'x')» that .NET appends.</summary>
|
||||
public static string CleanMessage(ArgumentException exception)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(exception);
|
||||
return exception.ParamName is { } name ? exception.Message.Replace($" (Parameter '{name}')", string.Empty, StringComparison.Ordinal) : exception.Message;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Small helpers of the endpoints.</summary>
|
||||
|
||||
Reference in new issue
Block a user