c# - How To Deal With Exceptions In Large Code Bases -


I have a big C # code base, it seems quite a buggy at times, and I was thinking that the client PC But there is a quick way to improve the discovery and diagnosis of future issues.

The biggest pressure is that the exceptions are generated in the software, and even the report problem through me is that unless they are caught, the root cause of the exception is lost.

I.e. If an exception was caught in a specific method, 20 other methods are called by that method, and in those ways each 20 calls to other methods. You get the picture, it is impossible to understand an empty reference exception, especially if it happened on a client machine.

I have recently found some place where I think errors are more likely to happen and try to catch them directly, is this the only solution? I can be here for a long time.

I'm not an exception that the exception will bring the current process down (this is just a thread - not the main application), but I care that the exceptions do not help back and troubleshooting.

Any thoughts?

I know well that I am probably asking a question that looks silly, and can not be a direct answer. Everything will be good to discuss something.

Exception calls the call stack that you can use to detect the source of exception As long as the exception is incorrectly restored or swallowed in the past, I mean:

  try {// ...} Grip (exception e) {// throw stuff with exception; }  

instead of:

  try {// ...} hold (exception) {// stuff with throwing exception; }  

Later maintains the call stack while does not precede. Generally, the code should only catch exceptions, which, instead of all exceptions, plans to handle it. If the code is properly designed in this way, then when the most layer exception is spread on top, then you should be through the call stack that method started the series of events.


Comments