3 ms·
Exceptions for error handling... this is just error handling, that was my point. Returning a sentinel value (null) is just one (very suboptimal) way of handling
by NateDad 13y ago
Exceptions for error handling... this is just error handling, that was my point. Returning a sentinel value (null) is just one (very suboptimal) way of handling an error.
Instead of dataSource.getPersonById(id) returning null, it could throw a NotFoundException. This is better because it's a specific error (as opposed to a MalformedIdException, for example).