November 2, 2012

Just let it crash? No thanks

This blog post discusses the philosophy of not trying to catch every exception – let the app crash when you don’t understand or anticipate the problem

I agree that you shouldn’t just catch Exceptions, politely log them and then swallow them.    You then place the burden on yourself (or the operations guys) to actually realize that there’s a problem – the customer may not know – they may just think the app is horrible.   Without operational feedback, you’ll never know that the app is misbehaving.

Here’s what I do – in the situations where an unexpected Exception is thrown, I capture the exception, log it, send a polite error message to the user explaining that something went wrong, and then I email the stack trace to myself.

That way, I know when things have gone wrong.   This has saved me a dozen times – errors I didn’t know about, issues with disk space, issues with an edge condition that I thought was practically impossible.

So, my advice: don’t ignore the exceptions, don’t “just let it crash”.

instead: Recover, and behind the scenes, sound the alarm.