I work on a rather large web site. We currently have 4 web servers and an active passive db cluster running asp.net 2.0 with C#. Currently our exception handling is not trapping the correct exception being thrown. I have heard it is because server.getlasterror() is not thread safe (note: we currently do not use server.getlasterror().getbaseexception which, in my opinion, is why we are not getting the correct error). We are currently starting a project to trap exact exceptions so we can actually see the root cause of the error and I’m trying to find the best way to do it.
Our options are:
- Go through all of our classes/methods (hundreds, if not thousands) to add try/catch/finally blocks to trap the correct exception.
- Figure out a way to properly handle the exceptions in the global.asax.
So I guess my questions are:
Is server.getlasterror() thread safe?
If two exceptions are thrown at the same time, will both be logged?
Is there a better way to handle this than what I have listed?
Thanks for any help you can provide