3 ms·
Despite what CS and SE classes try to drill into you, null results or failure cases are nearly always better handled right when they happen instead of passing t
by Larrikin 4y ago
Despite what CS and SE classes try to drill into you, null results or failure cases are nearly always better handled right when they happen instead of passing them up with layers of exception handling. Log it, pass null up, and just immediately handle it. Fail early and none of the rest of the function matters.
Even types of exceptions are rarely useful results outside of reading the logs or sometimes in libraries outside of your control.
- 8note 4y agoThe most important considerations for errors is whether they can be retried, and who needs to change something to fix it. The types can be useful for communicating this
- za3faran 4y agoHow do you handle a DB connection time out in your stack? You can log it and retry, eventually the entire call must be terminated though, and the quickest way is through exception propagation.