473,382 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Exception Handling

Hi,

Considering the scenario for handling exceptions in Web Application where we
have Presentation layer, Business layer and Data Access layer; if there any
exception is occurred in DAL, which is the best thing to do:

1. Not to catch the exception in DAL and let it pop up to the Application
level and let the Global.Application_Error event, log it to any source and
show. Let ASP.NET show custom error page provided in Web.Config file.

OR

2. To Catch Exception in DAL, Log the error using some Exception Handling
mechanism and Tranfer the control to another page using
Server.Transfer("ErrorPage.aspx");

Which one of the above 1 or 2 is the best way to handle exceptions?

Regards
Iyer
Jul 19 '05 #1
1 3113
I'm personally of the opinion that you should only catch an exception if
you are expecting it and can recover gracefully from it. Otherwise it
should bubble its way all the way to the top of the call stack. I have a
logic in Application_OnError in global.asax.cs that logs any unhandled
exceptions to the Event Log and a database then displays a friendly
message to the user as well as shows debug information to specific users
inside the organization based on IP.

Hope that helps,
Rob Epstein
Sr Developer
Auctionworks, Inc.
"Nothing's impossible until proven so." - Me

Subramanian Iyer.NET wrote:
Hi,

Considering the scenario for handling exceptions in Web Application where we
have Presentation layer, Business layer and Data Access layer; if there any
exception is occurred in DAL, which is the best thing to do:

1. Not to catch the exception in DAL and let it pop up to the Application
level and let the Global.Application_Error event, log it to any source and
show. Let ASP.NET show custom error page provided in Web.Config file.

OR

2. To Catch Exception in DAL, Log the error using some Exception Handling
mechanism and Tranfer the control to another page using
Server.Transfer("ErrorPage.aspx");

Which one of the above 1 or 2 is the best way to handle exceptions?

Regards
Iyer


Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: adi | last post by:
Dear all, This is more like a theoretical or conceptual question: which is better, using exception or return code for a .NET component? I had created a COM object (using VB6), which uses...
6
by: Daniel Wilson | last post by:
I am having exception-handling and stability problems with .NET. I will have a block of managed code inside try...catch and will still get a generic ..NET exception box that will tell me which...
7
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
3
by: Master of C++ | last post by:
Hi, I am an absolute newbie to Exception Handling, and I am trying to retrofit exception handling to a LOT of C++ code that I've written earlier. I am just looking for a bare-bones, low-tech...
2
by: tom | last post by:
Hi, I am developing a WinForm application and I am looking for a guide on where to place Exception Handling. My application is designed into three tiers UI, Business Objects, and Data Access...
9
by: C# Learner | last post by:
Some time ago, I remember reading a discussion about the strengths and weaknesses of exception handling. One of the weaknesses that was put forward was that exception handling is inefficient (in...
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
4
by: Ele | last post by:
When Exception handling disabled compiler still spits out "C++ exception handler used." Why is that? Why does it ask for "Specify /EHsc"? Thanks! c:\Program Files\Microsoft Visual Studio...
41
by: Zytan | last post by:
Ok something simple like int.Parse(string) can throw these exceptions: ArgumentNullException, FormatException, OverflowException I don't want my program to just crash on an exception, so I must...
1
by: George2 | last post by:
Hello everyone, Such code segment is used to check whether function call or exception- handling mechanism runs out of memory first (written by Bjarne), void perverted() { try{
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.