frazer said:
1 when i get an error in my code where the error is not handled,
all i get is a system error, i dont get detailed information that i get when
the code is in a try catch block.
how do i get that info at runtime without having to add a try catch block
Why wouldn't you want to use a try catch block? You don't need every
function wrapped, but the callers of functions should have them..
2 also how do i handle exceptions at one place. or do i have to write try
catch everywhere?
Don't do this... you may want some top level handlers but Exception handlers
are there to allow you to respond effectively to problems, many of which you
can't control. There are sooo many things that can go wrong that generic
handlers are really terrible if you aren't using specific ones. You don't
need try catches everywhere, you can let the exception propogate up, but you
should probably use them in most places and rethrow them.... an IOException
is totally different beast then SqlException caused by a timeout...so how
could one handler effectively handle them both unless it's basically just
eating it?
Not trying to lecture but what you are asking is really a recipe for
trouble.. I'd highly recommend reading up on this so you truly understand
why this is a really bad practice
http://msdn.microsoft.com/theshow/Episode008/Richter.html
There are tons of examples out there but you really should only catch stuff
you are expecting and Respond to it with your handler. Or throw it uup the
stack for someone else to handle. but don't just eat it and treat all
exceptions like they are the same, they are very very different.
HTH,
Bill