2021-11-30 14:32:10 +01:00
|
|
|
using Microsoft.AspNetCore.Diagnostics;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
2021-12-01 13:03:06 +01:00
|
|
|
namespace zero.Api.Endpoints.Error;
|
2021-11-30 14:32:10 +01:00
|
|
|
|
|
|
|
|
public class ErrorController : ZeroApiController
|
|
|
|
|
{
|
|
|
|
|
[HttpGet("")]
|
|
|
|
|
public virtual ActionResult<ApiResponse> Index()
|
|
|
|
|
{
|
|
|
|
|
IExceptionHandlerFeature exception = HttpContext.Features.Get<IExceptionHandlerFeature>();
|
|
|
|
|
|
|
|
|
|
return new ErrorApiResponse()
|
|
|
|
|
{
|
|
|
|
|
Success = false,
|
|
|
|
|
Status = HttpContext.Response.StatusCode,
|
|
|
|
|
Error = new()
|
|
|
|
|
{
|
|
|
|
|
ApiPath = exception.Path,
|
|
|
|
|
Message = exception.Error.Message
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|