Is there a situation when it's appropriate to use empty catch block?

bniwredyc picture bniwredyc · Jan 14, 2011 · Viewed 9.5k times · Source

Possible Duplicates:
Why are empty catch blocks a bad idea?
Is there any valid reason to ever ignore a caught exception

Do you know any situations when an empty catch block is not the absolute evil?

try
{
    ...
    // What and When?
    ...
}
catch { }

Answer

as-cii picture as-cii · Jan 14, 2011

There are a lot of questions on this, try to look at:

Why are empty catch blocks a bad idea?

From that post's accepted answer:

Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.

It's the programming equivalent of putting black tape over an engine warning light.