Handle unhappy paths for the multiple items endpoint (#14199)
This commit is contained in:
committed by
GitHub
parent
0f1c2f7022
commit
83230d377c
@@ -1,6 +1,9 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Umbraco.Cms.Api.Common.Builders;
|
||||
using Umbraco.Cms.Api.Delivery.Routing;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Core.DeliveryApi;
|
||||
using Umbraco.Cms.Core.Services.OperationStatus;
|
||||
|
||||
namespace Umbraco.Cms.Api.Delivery.Controllers;
|
||||
|
||||
@@ -17,4 +20,25 @@ public abstract class ContentApiControllerBase : DeliveryApiControllerBase
|
||||
ApiPublishedContentCache = apiPublishedContentCache;
|
||||
ApiContentResponseBuilder = apiContentResponseBuilder;
|
||||
}
|
||||
|
||||
protected IActionResult ApiContentQueryOperationStatusResult(ApiContentQueryOperationStatus status) =>
|
||||
status switch
|
||||
{
|
||||
ApiContentQueryOperationStatus.FilterOptionNotFound => BadRequest(new ProblemDetailsBuilder()
|
||||
.WithTitle("Filter option not found")
|
||||
.WithDetail("One of the attempted 'filter' options does not exist")
|
||||
.Build()),
|
||||
ApiContentQueryOperationStatus.IndexNotFound => BadRequest(new ProblemDetailsBuilder()
|
||||
.WithTitle("Examine index not found")
|
||||
.WithDetail($"No index found with name {Constants.UmbracoIndexes.DeliveryApiContentIndexName}")
|
||||
.Build()),
|
||||
ApiContentQueryOperationStatus.SelectorOptionNotFound => BadRequest(new ProblemDetailsBuilder()
|
||||
.WithTitle("Selector option not found")
|
||||
.WithDetail("The attempted 'fetch' option does not exist")
|
||||
.Build()),
|
||||
ApiContentQueryOperationStatus.SortOptionNotFound => BadRequest(new ProblemDetailsBuilder()
|
||||
.WithTitle("Sort option not found")
|
||||
.WithDetail("One of the attempted 'sort' options does not exist")
|
||||
.Build()),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user