| File: Infrastructure\ProblemDetailsClientErrorFactory.cs | Web Access |
| Project: src\aspnetcore\src\Mvc\Mvc.Core\src\Microsoft.AspNetCore.Mvc.Core.csproj (Microsoft.AspNetCore.Mvc.Core) |
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Microsoft.AspNetCore.Mvc.Infrastructure; internal sealed class ProblemDetailsClientErrorFactory : IClientErrorFactory { private readonly ProblemDetailsFactory _problemDetailsFactory; public ProblemDetailsClientErrorFactory(ProblemDetailsFactory problemDetailsFactory) { _problemDetailsFactory = problemDetailsFactory ?? throw new ArgumentNullException(nameof(problemDetailsFactory)); } public IActionResult GetClientError(ActionContext actionContext, IClientErrorActionResult clientError) { var problemDetails = _problemDetailsFactory.CreateProblemDetails(actionContext.HttpContext, clientError.StatusCode); return new ObjectResult(problemDetails) { StatusCode = problemDetails.Status, ContentTypes = { "application/problem+json", "application/problem+xml", }, }; } }