Vita Rara: A Life Uncommon

Don't Swallow Exceptions


Categories: |

Over the past two days I've been trouble shooting an application for a client. It's an old Java server application based on the Enhydra Framework and EJB 1.1. It's old.

I had most everything working but something in the system was throwing an exception that the code was swallowing and just display a page that said an exception had been thrown. No log message, no stack trace, nothing. Don't ever do this. If you don't have a system wide means of handling exceptions at least put in an e.printStackTrace(). It's the least you can do.

Eventually we had to go to the vendor, who no longer really supports the application, and have them add the e.printStackTrace() statement so we could debug the application. One line was all it took to fix the issue.

So, the moral of the story is don't ever just swallow an Exception and just display an error message. Do something with it!