Posts Tagged: exception handling

An Approach to Exception Handling

[In response to this post, also posted here, asking about guidelines different developers have come up with….  I actually started a response on the site, then realized I was typing an entire essay into a little comment box.]

Guideline #1: Never discard exception information.

You might either wrap the exception and throw the wrapper, or log it somehow — but discarding exception information should always set off loud alarm bells.  Likewise, catching an exception and throwing a new exception is bad if you neglect to wrap the original one — that stack trace is valuable!

Close
Powered by ShareThis (custom mod)