Re:Ask HN: What is your best advice for a junior software de...
by debaserab2 on Wednesday October 03, 2018 @02:43PM
(#18133413)
In what case would you ever want the second example?
[ Parent
| on HN ]
Re:Ask HN: What is your best advice for a junior software de...
by orangepenguin on Wednesday October 03, 2018 @03:39PM
(#18134030)
Always. If you can't resolve the exception and continue processing normally, you should never discard the exception you caught and create a new one of your own. If you must create one of your own, include the one you caught for the additional context.
It's pretty frustrating when you're debugging someone else's code and their error handling just throws away all of the useful information and replaces it with a generic "Something broke" kind of message.
Re:Ask HN: What is your best advice for a junior software de...
by elsombrero on Wednesday October 03, 2018 @03:07PM
(#18133710)
usually you may catch a general exception and throw another one that's caught up the call stack.
In this case i think it may be useful for logging additional causes that are not going to be obvious with just the stacktrace(?)