Mostly Linux & Python syntax notes and hyperlinks.

Thursday, May 16, 2013

Python: don't catch an exception if you don't know what to do with it

Big complicated tangle of code. Lots of utility methods called from different places. We got in the habit of every method enclosing a try... Except block.

But sometimes it's better to propagate an exception up to the calling method. It will know what to do about it and be closer to the error logging needed.

We missed catching some error conditions soon enough because they were lost inside a utility that trapped the exception but didn't handle it right.

No comments:

Post a Comment