?
Solved

How to implement exception handling in a 3 tier web app

Posted on 2011-02-10
3
Medium Priority
?
395 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 18

Accepted Solution

by:
Anil Golamari earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

800 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