Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions ArenaService/Filters/CalcAOFailedExceptionFilter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace ArenaService.Filter;

using ArenaService.Shared.Exceptions;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;

public class CalcAOFailedExceptionFilter : IExceptionFilter
{
public void OnException(ExceptionContext context)
{
if (context.Exception is CalcAOFailedException)
{
context.Result = new ObjectResult(new { error = "Total ranking count is under 40." })
{
StatusCode = StatusCodes.Status423Locked,
};
context.ExceptionHandled = true;
}
}
}
2 changes: 2 additions & 0 deletions ArenaService/Setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace ArenaService;
using ArenaService.Options;
using ArenaService.Services;
using ArenaService.Shared.Data;
using ArenaService.Shared.Exceptions;
using ArenaService.Shared.Jwt;
using ArenaService.Shared.Repositories;
using ArenaService.Shared.Services;
Expand Down Expand Up @@ -85,6 +86,7 @@ headlessOptions.Value.JwtSecretKey is not null
options.Filters.Add<CacheExceptionFilter>();
options.Filters.Add<NotRegisteredUserExceptionFilter>();
options.Filters.Add<NotEnoughMedalExceptionFilter>();
options.Filters.Add<CalcAOFailedExceptionFilter>();
})
.AddNewtonsoftJson(options =>
{
Expand Down
Loading