Results 1 to 4 of 4

Thread: Exception management in multi tier web apps

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    Exception management in multi tier web apps

    I have adesigned quite a few asp.net apps, all working almost identically.

    I start off with 3 tiers

    Data (Class library)

    Business(Class library)

    Presentation (asp.net or winforms)


    I suspect many other asp.net devs design their code in perhaps the same way, or in even more tiers, if you adhere to the SOA architecture.
    What im curious to know is that how do you handle exceptions in your asp.net apps, and how do you display information to the user? Do you use custom exceptions? Where in the tiered design do you log the exceptions?

    I use this design:

    Datatier:
    try
    ...here i create db object, make query

    catch
    throw

    finally
    ...close db connection dispose db object


    Businesstier:

    try

    ...I call my shared datatier method and returns either datareader or dataset

    catch
    throw new applicationexception("An error occured when trying to save the user",ex)
    ...I wrap the exception and deliver a text message to the user including the inner exception




    presentationtier:

    try
    ...some action like pressing a button

    catch

    logexception(ex) <--i use the logging component to log the exception and all its inner ones

    showmessagebox(ex.message) <----javascript messagebox



    There you have it... what do you think of this design? Should I perhaps log the exception in the business tier?

    How do you other pros write your exception management architecture?

    kind regards
    Henrik

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    Re: Exception management in multi tier web apps

    I guess no one likes exceptionmanagement eh
    Come on, any architects here?

    /Henrik

  3. #3
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704

    Re: Exception management in multi tier web apps

    Generally, data layers should swallow errors, log them, and then rethrow them.

    An error related to a data error that involves a custom object, like Registrant ie, should throw an InvalidRegistrant error (custom errors).

    On the business side, again, custom objects should have their own custom exceptions.

  4. #4
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870

    Re: Exception management in multi tier web apps

    Hi MrNorth,

    I only handle the errors at each level, logging them, and then re-throwing them if necessary.
    I have a question regarding the 'multi-tier' approach we use here:
    http://www.vbforums.com/showthread.php?t=327915
    Any input would be much appreciated

    Many thanks
    Nick
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

Posting Permissions

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



Click Here to Expand Forum to Full Width