diff --git a/src/Extensions/src/Eventuous.Extensions.AspNetCore/Http/HttpCommandMappingExt.cs b/src/Extensions/src/Eventuous.Extensions.AspNetCore/Http/HttpCommandMappingExt.cs index 818972a6..0f1d9a2d 100644 --- a/src/Extensions/src/Eventuous.Extensions.AspNetCore/Http/HttpCommandMappingExt.cs +++ b/src/Extensions/src/Eventuous.Extensions.AspNetCore/Http/HttpCommandMappingExt.cs @@ -1,8 +1,6 @@ // Copyright (C) Ubiquitous AS. All rights reserved // Licensed under the Apache License, Version 2.0. -// ReSharper disable once CheckNamespace - using Eventuous.Extensions.AspNetCore; // ReSharper disable once CheckNamespace diff --git a/src/Extensions/src/Eventuous.Extensions.AspNetCore/Http/ResultExtensions.cs b/src/Extensions/src/Eventuous.Extensions.AspNetCore/Http/ResultExtensions.cs index 164dafdd..1e65703d 100644 --- a/src/Extensions/src/Eventuous.Extensions.AspNetCore/Http/ResultExtensions.cs +++ b/src/Extensions/src/Eventuous.Extensions.AspNetCore/Http/ResultExtensions.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Http; using static Microsoft.AspNetCore.Http.StatusCodes; +// ReSharper disable once CheckNamespace namespace Eventuous.Extensions.AspNetCore; static class ResultExtensions { @@ -37,22 +38,16 @@ static IResult AsValidationProblem(Result.Error error, int statusCode) } ); - static ActionResult AsProblem(Result.Error error, int statusCode) => new ObjectResult(CreateResult(error, new ProblemDetails(), statusCode)); + static ActionResult AsProblem(Result.Error error, int statusCode) => CreateResult(error, new ProblemDetails(), statusCode); static ActionResult AsValidationProblem(Result.Error error, int statusCode) => CreateResult(error, new ValidationProblemDetails(error.AsErrors()), statusCode); - static ActionResult CreateResult(Result.Error error, T details, int statusCode) where T : ProblemDetails { - details.Status = statusCode; - details.Title = error.ErrorMessage; - details.Detail = error.Exception?.ToString(); - details.Type = error.Exception?.GetType().Name; - - return new ObjectResult(details) { - StatusCode = Status400BadRequest, + static ActionResult CreateResult(Result.Error error, T details, int statusCode) where T : ProblemDetails + => new ObjectResult(PopulateDetails(details, error, statusCode)) { + StatusCode = statusCode, ContentTypes = [ContentTypes.ProblemDetails] }; - } } static T PopulateDetails(T details, Result.Error error, int statusCode) where T : ProblemDetails where TState : State, new() {