| | | 1 | | using System; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | using System.Linq; |
| | | 4 | | using System.Threading.Tasks; |
| | | 5 | | using Microsoft.AspNetCore.Authorization; |
| | | 6 | | using Microsoft.AspNetCore.Diagnostics; |
| | | 7 | | using Microsoft.AspNetCore.Http; |
| | | 8 | | using Microsoft.AspNetCore.Mvc; |
| | | 9 | | using Microsoft.Extensions.Logging; |
| | | 10 | | using SVETA.Api.Data.DTO; |
| | | 11 | | |
| | | 12 | | namespace SVETA.Api.Controllers |
| | | 13 | | { |
| | | 14 | | [Route("api/v1/Error")] |
| | | 15 | | [ApiController] |
| | | 16 | | public class ErrorController : ControllerBase |
| | | 17 | | { |
| | | 18 | | private ILogger<ErrorController> _logger; |
| | 0 | 19 | | public ErrorController(ILogger<ErrorController> logger) => _logger = logger; |
| | | 20 | | |
| | | 21 | | [HttpGet("Error")] |
| | | 22 | | [AllowAnonymous] |
| | | 23 | | public IActionResult Error() |
| | 0 | 24 | | { |
| | 0 | 25 | | var exceptionHandlerPathFeature = HttpContext.Features.Get<IExceptionHandlerPathFeature>(); |
| | | 26 | | |
| | 0 | 27 | | _logger.LogError(message: exceptionHandlerPathFeature?.Path + ": " + exceptionHandlerPathFeature?.Error.Mess |
| | | 28 | | |
| | 0 | 29 | | return StatusCode(StatusCodes.Status500InternalServerError, new ErrorDTO |
| | 0 | 30 | | { |
| | 0 | 31 | | error = exceptionHandlerPathFeature?.Error.Message |
| | 0 | 32 | | }); |
| | 0 | 33 | | } |
| | | 34 | | } |
| | | 35 | | } |