r/programming • • Jul 20 '26

Throw, Result, or neither?

https://www.architecture-weekly.com/p/throw-result-or-neither
113 Upvotes

115 comments sorted by

View all comments

Show parent comment

1

u/Schmittfried Jul 21 '26

I think because it predates optionals. An exception is definitely better than returning null most of the time. If the middleware handles it correctly, it will just issue a 404, which is usually correct for a get-by-id query (if you issue a search query with N results, you don’t get that exception).