java api design - NULL or Exception
- by srini.venigalla
Is it better to return a null value or throw an exception from an API method?
Returning a null requires ugly null checks all over, and cause a major quality problem if the return is not checked.
Throwing an exception forces the user to code for the faulty condition, but since Java exceptions bubble up and force the caller code to handle them, in general, using custom exceptions may be a bad idea (specifically in java).
Any sound and practical advice?