Solved

How to implement exception handling in a 3 tier web app

Posted on 2011-02-10
3
394 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 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 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