Re:You’re better off using Exceptions
by dnautics on Monday February 03, 2020 @01:38PM
(#22227370)
I don't see what the problem is. The API should expose two methods: `fetch()` which returns, say, nil if there's no result (or an error monad or error tuple, depending on your language), and say `fetch!()` (or `fetch_throws()` if your language doesn't support exclamation points) which raises an exception if there isn't a result. The programmer gets to choose, on a case-by-case basis.
[ Parent
| on HN ]
Re:You’re better off using Exceptions
by iainmerrick on Monday February 03, 2020 @03:02PM
(#22228344)
Agreed, it’s ideal to have both options available.
Kotlin gets this right for the most part (although I think it would be better if it had checked exceptions).