2 ms·
I throw exceptions for anything that isn't an expected result. Request a row from a database that doesn't exist throws an exception NoResults let the caller dec
by dangerface 4y ago
I throw exceptions for anything that isn't an expected result. Request a row from a database that doesn't exist throws an exception NoResults let the caller decide what to do.
The caller can then recover from the exception by searching else where or using a default etc.
If the exception can not be recovered then its an error. If its a user error like asking for a result that doesn't exist ill notify the user without logging. If its an unexpected error the exception is unhandled and bubbled up to a global exception handler that logs to a file.
Some times ill setup an email on error if the code is important enough.