mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 07:13:12 +00:00
21 lines
574 B
C#
21 lines
574 B
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.Filters;
|
|
|
|
namespace Api.SeaHavenIndustries.Filters
|
|
{
|
|
public class ArgumentExceptionFilter : IExceptionFilter
|
|
{
|
|
public void OnException(ExceptionContext context)
|
|
{
|
|
if (context.Exception is not ArgumentException ex) return;
|
|
|
|
context.Result = new BadRequestObjectResult(new
|
|
{
|
|
status = "Error",
|
|
message = ex.Message,
|
|
code = 400
|
|
});
|
|
context.ExceptionHandled = true;
|
|
}
|
|
}
|
|
}
|