Exception handling Approach
-
Hi I am developing an asp.net site with 5 layers as UI, DAO, DTO, Business and DAL. I am confused where should i do exception handling. Do i need to do it on each tier code or just i do it on UI layer.....Please suggest. I am planning to use resource file and log4net. And for all layers except UI, i am planning to maintain trace on log file and on the other hand for UI i will display error on custom error.aspx page and as well as on log file..... Am i correct, as i am doing n tier application first time. Is there any other simpler and full proof way......PLEASE SUGGEST... Amit
-
Hi I am developing an asp.net site with 5 layers as UI, DAO, DTO, Business and DAL. I am confused where should i do exception handling. Do i need to do it on each tier code or just i do it on UI layer.....Please suggest. I am planning to use resource file and log4net. And for all layers except UI, i am planning to maintain trace on log file and on the other hand for UI i will display error on custom error.aspx page and as well as on log file..... Am i correct, as i am doing n tier application first time. Is there any other simpler and full proof way......PLEASE SUGGEST... Amit
Amit Kumar G wrote:
Is there any other simpler and full proof way
Yeah, don't run the app, that way you will never get any exceptions ;P You should handle the exception in the code where it happens. If it is something that can be corrected, then do so, otherwise rethrow it up the call stack. I'm curious as to why you think you need so many layers? I would suggest using the Enterprise Library Exception Handling Block. It is easy to configure and setup multiple policies for different exceptions and situations.
only two letters away from being an asset
-
Amit Kumar G wrote:
Is there any other simpler and full proof way
Yeah, don't run the app, that way you will never get any exceptions ;P You should handle the exception in the code where it happens. If it is something that can be corrected, then do so, otherwise rethrow it up the call stack. I'm curious as to why you think you need so many layers? I would suggest using the Enterprise Library Exception Handling Block. It is easy to configure and setup multiple policies for different exceptions and situations.
only two letters away from being an asset
I agree with you, but to buy bread i have to run the application:)) Jokes apart. I appreciate your reply. Can you help me to understand how i can use enterprise library. I have zero idea for this. Cheers Amit
-
I agree with you, but to buy bread i have to run the application:)) Jokes apart. I appreciate your reply. Can you help me to understand how i can use enterprise library. I have zero idea for this. Cheers Amit
Download it from here http://www.gotdotnet.com/codegallery/codegallery.aspx?id=295a464a-6072-4e25-94e2-91be63527327[^] There are quick starts and examples that should get you going.
only two letters away from being an asset
-
Hi I am developing an asp.net site with 5 layers as UI, DAO, DTO, Business and DAL. I am confused where should i do exception handling. Do i need to do it on each tier code or just i do it on UI layer.....Please suggest. I am planning to use resource file and log4net. And for all layers except UI, i am planning to maintain trace on log file and on the other hand for UI i will display error on custom error.aspx page and as well as on log file..... Am i correct, as i am doing n tier application first time. Is there any other simpler and full proof way......PLEASE SUGGEST... Amit
Hi, you can use microsoft enterprise library for exception handling and database operations. That will log the exception on the event viewer. Catch the exceptions in all layers, but log the exception only from the UI layer. Throw exceptions from other layers to the UI layer. Istead of using enterprise library, you can log your events and exceptions with datatime on a text file in a specific directory. Those files can be used to keep track of the execution. Ram