3 ms·
Of course, if you're in a web app, and you've received an email address, and you can't find a User record for that email address, a perfectly valid approach wou
by barrkel 7y ago
Of course, if you're in a web app, and you've received an email address, and you can't find a User record for that email address, a perfectly valid approach would be for the fetch to throw a 'not found' exception and to generically handle all 'not found' exceptions in request handlers to return 404 status codes.
- appleiigs 7y agoThen would you be nesting a number of exceptions. Some maybe real 404 exceptions, but some would be zero records found. And I think the zero records found should be handled in the business logic (if statements, switch/case), not in the exceptions.
- joshuamorton 7y agoIf I expect exactly one result, zero results is exceptional. If I expect zero or more results, zero results should be handled by the business logic.
- barrkel 7y agoThe expectation of a single result should be encoded in the API, not the business logic. It's a very common expectation for e.g. identifiers found on http paths.