fix(listings): return 404 instead of 500 for non-existent listing detail
Move not-found handling from the query handler to the controller layer following DDD conventions: the handler now returns null when a listing is not found, and the controller maps that to NotFoundException (404). Key changes: - Handler returns ListingDetailData | null instead of throwing - Use ListingNotFoundSignal to prevent caching null results - Add `return await` to properly catch errors in try/catch - Controller throws NotFoundException with listing ID in message - Strengthen E2E test to assert exactly 404 (was [404, 400]) - Add unit tests: not-found returns null, unexpected error → 500 - Fix missing LoggerService mock in handler test Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -142,7 +142,7 @@ test.describe('Listings API', () => {
|
||||
const res = await request.get('listings/non-existent-id-12345');
|
||||
|
||||
expect(res.ok()).toBeFalsy();
|
||||
expect([404, 400]).toContain(res.status());
|
||||
expect(res.status()).toBe(404);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user