This commit is contained in:
Bjarke Berg
2020-05-19 14:02:12 +02:00
parent 35680bba46
commit bff9477c31
6 changed files with 92 additions and 43 deletions

View File

@@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Net;
using System.Runtime.Serialization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
namespace Umbraco.Web.Common.Exceptions
{
@@ -14,6 +16,22 @@ namespace Umbraco.Web.Common.Exceptions
Value = value;
}
public HttpResponseException(ActionResult actionResult)
{
Status = actionResult switch
{
IStatusCodeActionResult x => (HttpStatusCode)x.StatusCode.GetValueOrDefault((int)HttpStatusCode.InternalServerError),
_ => HttpStatusCode.InternalServerError
};
Value = actionResult switch
{
ObjectResult x => x.Value,
_ => null
};
}
public HttpStatusCode Status { get; set; }
public object Value { get; set; }