3 ms·
Nothing about checked exceptions inherently prevents the failure scenarios you list, particularly the one about the power failure.
by leothekim 8y ago
Nothing about checked exceptions inherently prevents the failure scenarios you list, particularly the one about the power failure.
- leothekim 8y agoAlso, I gave a bad example for empty try catch. In this case, I would want a runtime exception thrown. Apologies for misleading the conversation.
- hyperman1 8y agoIn that case, you avoided disaster and I'm starting to agree with you.
- hyperman1 8y agoCorrect, this was about swallowing errors instead of rethrowing/handling. Checked exceptions are good if you want to be sure your caller does something when things go south. Some examples from my experience: * Most things that should be told to the end user, i.e. Business Exceptions. E.g. a webshop user tries to buy something but your stock has been emptied why he was deciding if he should buy or not. * Follow-up after a modification: If you wrote half a file, you can delete it in your catch IOException instead of letting it linger around. My company has a tendency to pick up and process any file found in an output directory as soon as you release the file lock. But just not filling your disk is good enough for me as reason.