as is
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace StopShopping.AdminApi.Middlewares;
|
||||
|
||||
public static class ProblemDetailsExtensions
|
||||
{
|
||||
private const string CODE_FIELD = "code";
|
||||
public static ProblemDetails AddErrorCode(this ProblemDetails problemDetails, ProblemDetailsCodes code)
|
||||
{
|
||||
problemDetails.Extensions ??= new Dictionary<string, object?>();
|
||||
|
||||
problemDetails.Extensions.Add(CODE_FIELD, (int)code);
|
||||
return problemDetails;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ProblemDetailsCodes
|
||||
{
|
||||
CsrfValidationFailed = 1000,
|
||||
ParametersValidationFailed = 1001,
|
||||
BadParameters = 1002,
|
||||
ServerError = 1003,
|
||||
}
|
||||
Reference in New Issue
Block a user