4 ms·
In what case would you ever want the second example?
by debaserab2 8y ago
In what case would you ever want the second example?
- elsombrero 8y agousually 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(?)
- orangepenguin 8y agoAlways. 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.
- deleted 8y ago[deleted]