Reputation: 83
I am not sure about this answer. I cant find it anywhere. Is it the empty error handling?!
Upvotes: 5
Views: 13852
Reputation: 11
From what i know, this means that in fancy talk "Eating the exception", but simply it just stops this specific error from stoping java while its running your code. Also the "e" part in the
catch (Exception *e*) {}
is the "name" for the error object.
if you're still unsure about whats that then read this.
Upvotes: 1
Reputation: 6083
We affectionately call this "eating the exception" at work. Basically, it means that something bad occurred, and we are burying our head in the sand and pretending it never happened. At the very least, a good practice is to have a logger.error(e) within that block:
try {
// code here
}
catch (Exception e) { logger.error(e); }
so that you will have it recorded somewhere that an exception occurred.
Upvotes: 4
Reputation: 531
I call it "exception masking" and it is not good style. It is best to catch specific exceptions or let them "bubble up". Masking exceptions will come back to bite you. It is a good idea to have the exceptions bubble up to be appropriately handled. If the exception "bubbles to the top", a proactive exception handler can be developed to notify the developer or organization that an unexpected exception has occurred.
Upvotes: 0
Reputation: 53694
It's called "broken code".
(if you want to ignore an exception, then clearly document the reason.)
Upvotes: 1
Reputation: 18354
This is generally called as ignoring an exception. Other terms used are Consuming an exception silently, Eating an exception etc
Upvotes: 2
Reputation: 39907
It is known as suppressing the exception, or swallowing the exception. May not be a very good practice, unless commented with a very good reason.
Upvotes: 5
Reputation: 129547
As far as I know, it's simply called an "empty catch clause" (or perhaps silent exception consumption), and it should generally be avoided (either handle the exception properly or don't try to catch it at all).
Upvotes: 2