I recently made the statement to a colleague that:
NullReferenceExceptions should never be explicitly caught
I used the word never…. hmmm. I’ve never seen a appropriate use case myself for catching them but I wanted to check if anyone else has?
Never is such a strong word after all…..
It depends on why; see Eric Lippert’s blog entry. If they are ‘boneheaded exceptions’, then no – just fix the calling code. In the rare case that they are ‘vexing exceptions’ (i.e. the code you are calling has traps that are hard to avoid), then I guess you’d have to.