www.webdeveloper.com
Results 1 to 5 of 5

Thread: exception chaining in .NET ?

  1. #1
    Join Date
    May 2004
    Posts
    8

    Question exception chaining in .NET ?

    Hi

    I have a three tier application(front end windows application, webservice, database). If the exception occurs in the database layer then that exception has to propagate through the webservice to front end user.

    In java there is a concept called chained exceptions. Does anything similar concept exist in .net framework?

    If not how I can propagate the exception and display a user friendly error message to the end user?

    Thanks
    Kantesh Vernekar

  2. #2
    Join Date
    Nov 2002
    Location
    Auburn, AL
    Posts
    9,222
    I am not familiar with chained exceptions in java, even though I know java. Sorry

  3. #3
    Join Date
    Aug 2006
    Posts
    1

    its possible

    yes there is and i think we have to rethrow the exception and exception will be wrapped at each level

    i am working on this

    Quote Originally Posted by kantesh13
    Hi

    I have a three tier application(front end windows application, webservice, database). If the exception occurs in the database layer then that exception has to propagate through the webservice to front end user.

    In java there is a concept called chained exceptions. Does anything similar concept exist in .net framework?

    If not how I can propagate the exception and display a user friendly error message to the end user?

    Thanks
    Kantesh Vernekar

  4. #4
    Join Date
    Aug 2006
    Posts
    29
    It should float up until it's caught at whatever level you want. If you don't catch it, it will de displayed to the user. If you have a base Page class that all of your pages derive from, I'd catch it in the Page_Error event and handle it accordingly. If you don't have a model like that... I'd def. recommend it..

  5. #5
    Join Date
    Aug 2006
    Location
    Lahore, Pakistan
    Posts
    23
    Use this chain for exception propogation

    Code:
    In DAL  if expection occurs
    
    try{
    }
    
    catch (Exception ex){
     throw ex;
    }
    
    In Web Service  if expection occurs
    
    try{
    }
    
    catch (Exception ex){
     throw ex;
    }
    
    In .aspx if expection occurs
    
    try{
    }
    
    catch (Exception ex){
     //  code goes here to show some message to end user
    }
    The Page_Error event is used as a final handler to the exception raised on a page.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles