private void HandleUnknownException(ExceptionContext context) { ProblemDetailsBase details = default; details = new ProblemDetailsBase { Status = StatusCodes.Status500InternalServerError, Title = "An error occurred while processing your request.", Type = "https://tools.ietf.org/html/rfc7231#section-6.6.1", Instance = context.HttpContext.Request.Path }; if (_environment.IsDevelopment()) { details.Detail = context.Exception.ToString(); } _logger.LogError($"Unhandled error: {context.Exception}"); context.Result = new ObjectResult(details) { StatusCode = StatusCodes.Status500InternalServerError }; context.ExceptionHandled = true; }
public ApiError(ProblemDetailsBase problemDetails, HttpStatusCode statusCode) { ProblemDetails = problemDetails; StatusCode = statusCode; }