Reputation: 35
What exactly is eating an exception? Is it when there's nothing in the catch block or when you don't log the exception?
I understand that this is eating an exception.
try {
//exception code
} catch (Exception e) {
}
However, what about this?
try {
//exception code
} catch (Exception e) {
System.out.println("Exception Thrown");
}
Upvotes: 2
Views: 541
Reputation: 160
When there is nothing in the catch block.
In general it is necessary to catch the more specific exception if it is possible to recover that exception and if not log the exception and rethrown it.
A program that "eat" exception is a bad practice because could be in an inconsistent state.
Upvotes: 1