What is called when I say "catch (Exception e) {}" in Java?

I am not sure about this answer. I can not find it anywhere. Is this empty error handling ?!

+5
source share
6 answers

It is known as suppressing an exception or swallowing an exception. It may not be very good practice if you do not comment on it with a large share.

+5
source

As far as I know, it is simply called the “ catch catch option ” (or perhaps quiet consumption of exceptions), and should usually be avoided (either handle the exception properly, or not try to catch it at all).

+2
source

. , ..

+2

" " . , , - , , . , logger.error(e) :

try {
   // code here
}
catch (Exception e) { logger.error(e); }

- , .

+2

" ".

( , .)

+1

I call it “masking exceptions,” and it's not a good style. It’s best to catch certain exceptions or let them bubble. The disguise exception will return to bite you. It is a good idea for exception bubbles to be handled appropriately. If the exception is up bubbles, a proactive exception handler can be developed to notify the developer or organization of an unexpected exception.

0
source

All Articles