Detailed Exception Handling Resources?
Does anyone know of any good, detailed resources or books for best-practices on exception handling? I am looking to dive into a much deeper understanding of it, and am finding it hard. All the books I see over .NET, ASP.NET, etc. place little emphasis or detail on exception handling.
I am currently testing out a 3-tier ASP.NET application, with a presentation layer, business logic layer, and data layer, and want to know more about exactly when to throw errors, when to catch them, what layer to do them in, etc.
I don't want a simple google search on ".NET exception handling" and then having you post the first couple of links. I would like you to respond if you have quality, known resources that you have used or have found.
Re: Detailed Exception Handling Resources?
I dont know if this will be as in depth as you want but it contains lots of "best practice" advice and general tips on exception handling/throwing (as well as loads more): http://www.amazon.com/Framework-Desi...081603-6222806
I've not read the entire Exception Handling chapter yet but I don't think it goes in to anything about where/when to throw excpetions in N-Tier apps though.
Re: Detailed Exception Handling Resources?
That is a decent resource for when you are building APIs, but it is still only one small chapter on going over exceptions. I still haven't found a good resource that goes over exactly what layer I should actually catch/throw different types of errors in an N-tier app.
Re: Detailed Exception Handling Resources?
That depends on where you think your exceptions are going to be thrown. Should you derive your own custom exceptions for them? If one call fails, should you throw an exception or modify another variable that affects the system down the line. If you look at the framework, it has all types of exceptions that can get thrown depending on what happens.
I guess it's a matter of opinion where you feel an exception could be raised. It's like the butterfly effect almost.
Re: Detailed Exception Handling Resources?
Quote:
Originally Posted by
gigemboy
That is a decent resource for when you are building APIs, but it is still only one small chapter on going over exceptions. I still haven't found a good resource that goes over exactly what layer I should actually catch/throw different types of errors in an N-tier app.
To be honest I think that small chapter (roughly 40 pages) and MSDN are the best you are going to get... I dont really understand what you are expecting to find though - I dont think you will find a guide that is as specific as telling you where to throw which type of exceptions in an N-Tier app. As formlesstree says, its up to you to decide which exceptions get thrown where based on what you want to happen.
Re: Detailed Exception Handling Resources?
Well I guess I just don't know exactly when to throw and when to catch. Way down in the data layer, say I have a dataadapter.Fill method that I know could error out if a connection can't be made. Do I catch the error in the data layer? Do I throw it? Or do I not do anything and just allow it to happen and have the error caught in a try/catch block on the initial method call all the way up in the presentation layer? These types of questions are what I can't quite get my head around.
Re: Detailed Exception Handling Resources?
Depends on your architecture... we do our error handling some where in the middle... sort of... DA errors get caught in our remote objects, logged... transactions rolled back... and then the error is re-thrown, so that it crosses back to the client side, where we can display it to the user. So our error handling is done in the public method that we access via remoting, and not in the DA itself.
Other conventional wisdom says to handle it at the lowest, most direct way possible... of an sproc can error out, wrap that in a try-catch... which is at odds with what we're doing... for us, the lowest possible point is the transaction on the server.... so maybe we're not so far off from that.
Anywho, that's my two centavos.
-tg