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:
@@ -67,13 +67,11 @@ public class BeatServiceTests : ServiceTestFixture
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Reordering_with_an_unknown_beat_is_refused()
|
||||
public async Task Reordering_with_an_unknown_beat_returns_null_rather_than_throwing()
|
||||
{
|
||||
Beats.CreateAsync(_chapterId, new CreateBeatRequest("First")).Wait();
|
||||
await Beats.CreateAsync(_chapterId, new CreateBeatRequest("First"));
|
||||
|
||||
Assert.That(
|
||||
async () => await Beats.ReorderAsync(_chapterId, new ReorderBeatsRequest([Guid.NewGuid()])),
|
||||
Throws.TypeOf<NotFoundException>());
|
||||
Assert.That(await Beats.ReorderAsync(_chapterId, new ReorderBeatsRequest([Guid.NewGuid()])), Is.Null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -183,11 +183,10 @@ public class CharacterArcTests : ServiceTestFixture
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Reordering_with_an_unknown_stage_is_refused() =>
|
||||
public async Task Reordering_with_an_unknown_stage_returns_null_rather_than_throwing() =>
|
||||
Assert.That(
|
||||
async () => await Arcs.ReorderAsync(
|
||||
_characterId, new ReorderArcStagesRequest([Guid.NewGuid()])),
|
||||
Throws.TypeOf<NotFoundException>());
|
||||
await Arcs.ReorderAsync(_characterId, new ReorderArcStagesRequest([Guid.NewGuid()])),
|
||||
Is.Null);
|
||||
|
||||
[Test]
|
||||
public async Task The_character_page_sees_every_beat_they_appear_in_across_the_book()
|
||||
|
||||
@@ -46,12 +46,6 @@ public class ExceptionHandlingTests : ServiceTestFixture
|
||||
Throws.TypeOf<ArgumentException>());
|
||||
|
||||
[Test]
|
||||
public async Task An_embedded_reference_to_a_missing_parent_still_throws()
|
||||
{
|
||||
// Creating a chapter under a nonexistent project isn't a "look this up" miss — it's
|
||||
// an invalid precondition for the create, so it stays exceptional.
|
||||
Assert.That(
|
||||
async () => await Chapters.CreateAsync(Guid.NewGuid(), new CreateChapterRequest("Landfall")),
|
||||
Throws.TypeOf<NotFoundException>());
|
||||
}
|
||||
public async Task Creating_a_chapter_under_a_missing_project_returns_null_rather_than_throwing() =>
|
||||
Assert.That(await Chapters.CreateAsync(Guid.NewGuid(), new CreateChapterRequest("Landfall")), Is.Null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user