How To Deal With Exceptions In Large Code Bases

Posted by peter on Stack Overflow See other posts from Stack Overflow or by peter
Published on 2010-05-18T03:35:13Z Indexed on 2010/05/18 3:40 UTC
Read the original article Hit count: 235

Filed under:
|

Hi All,

I have a large C# code base. It seems quite buggy at times, and I was wondering if there is a quick way to improve finding and diagnosing issues that are occuring on client PCs.

The most pressing issue is that exceptions occur in the software, are caught, and even reported through to me. The problem is that by the time they are caught the original cause of the exception is lost.

I.e. If an exception was caught in a specific method, but that method calls 20 other methods, and those methods each call 20 other methods. You get the picture, a null reference exception is impossible to figure out, especially if it occured on a client machine.

I have currently found some places where I think errors are more likely to occur and wrapped these directly in their own try catch blocks. Is that the only solution? I could be here a long time.

I don't care that the exception will bring down the current process (it is just a thread anyway - not the main application), but I care that the exceptions come back and don't help with troubleshooting.

Any ideas?

I am well aware that I am probably asking a question which sounds silly, and may not have a straightforward answer. All the same some discussion would be good.

© Stack Overflow or respective owner

Related posts about c#

Related posts about exceptions