Warning. Rant coming...
I was working on a project last week that included code that looked sort of like this:
public bool SomeMethod()
{
try
{
// do some lengthy, involved, *critical* process that,
// if it fails, will cause the rest of the application to fail *forever*
// as it leaves a required, persisted resource in a corrupted state
}
catch
{
return false;
}
}
public void SomeOtherMethod()
{
SomeMethod();
}
Of course, when I was debugging an issue in this application, SomeMethod was failing, yet I had no idea because the author of the code decided to not only throw away the exception that was being thrown, but not bother to check the return value of SomeMethod after it was called.
So here comes the rant.
Stop it! Stop doing this! Stop catching exceptions and either doing nothing with them, or throwing them away! It's an exception handler! If you're not going to handle the exception, don't catch it!