Solved

How to implement exception handling in a 3 tier web app

Posted on 2011-02-10
3
386 Views
Last Modified: 2012-05-11
Hi,

I am new to the 3 tier development architecture and am looking to see what is the most common and efficient way to create error handling. Is it by creating a custom error handling object? Any help is much appreciated!
0
Comment
Question by:bschave2
3 Comments
 
LVL 18

Accepted Solution

by:
Anil Golamari earned 500 total points
ID: 34865532
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34865607
It depends entirely on what you need to do and what you need to report to the upper tiers. Trapping exceptions where they happen is usually best, and you will of course want to log them. You can then either re-throw the exception to, for example, let your UI know something went wrong. But whether you rethrow the original exception, or a more generic custom exception type is up to you.
0
 

Author Comment

by:bschave2
ID: 34866854
How can I pass the exception back to the UIl?

well say in the UIL I call an object in the UIL

BLL customers = new BLL();
customers.GetCustomers(gvCustomers);

in the BLL method I get the gridview:

public void GetCustomers(GridView gvCustomers)
    {

        DLL getGV = new DLL();
        gvCustomers.DataSource = getGV.getDS("getCusts");
        gvCustomers.DataBind();
    }

And in the DLL i have the method as

public DataSet getDS(string ProcName, SortedList<string, string> sqlParams)
    {
        try
        {
            getCon();
            cmd = new SqlCommand(ProcName, con);

            //Looping through params.
            foreach (KeyValuePair<string, string> Param in sqlParams)
            {
                cmd.Parameters.AddWithValue(Param.Key.ToString(), Param.Value.ToString());

            }
            da = new SqlDataAdapter(cmd);
            cmd.CommandType = CommandType.StoredProcedure;
            ds = new DataSet();
            da.Fill(ds);

            closeCon();
        }
        catch (SqlException sqlex)
        {
            throw new Exception(ex.message);
        }

        return ds;
    }
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now