Remove NotFoundException; services return null on lookup miss
A missing record isn't exceptional — services now return null (logged at Info) instead of throwing, and endpoints map null to 404. Agent and import toolsets route not-found through their existing OrNotFound result pattern rather than a caught exception.
This commit is contained in:
@@ -18,7 +18,13 @@ public static class ChapterEndpoints
|
||||
projectScoped.MapPost("/", async (
|
||||
Guid projectId, CreateChapterRequest request, ChapterService service, CancellationToken ct) =>
|
||||
{
|
||||
var created = (await service.CreateAsync(projectId, request, ct)).ToResponse();
|
||||
var chapter = await service.CreateAsync(projectId, request, ct);
|
||||
if (chapter is null)
|
||||
{
|
||||
return Results.NotFound();
|
||||
}
|
||||
|
||||
var created = chapter.ToResponse();
|
||||
return Results.Created($"/api/chapters/{created.Id}", created);
|
||||
})
|
||||
.WithSummary("Add a chapter.");
|
||||
|
||||
Reference in New Issue
Block a user