Re: Handling Exceptions in an n-tier environment
From: Raterus (moc.liamtoh_at_suretar.reverse)
Date: 08/24/04
- Next message: Lerp: "Re: which is best method?"
- Previous message: Preserved Moose: "Using an ASP.NET page to send a file to the printer"
- In reply to: Karl: "Re: Handling Exceptions in an n-tier environment"
- Next in thread: Bryant Hankins: "Re: Handling Exceptions in an n-tier environment"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 24 Aug 2004 15:32:27 -0400
hmm, Is there a good reason why I shouldn't issue a throw ex?
Try
somethingThatCanCauseAnError()
Catch ex As Exception
Throw ex
End Try
I can understand creating a new ApplicationException with additional details, but sometimes all I need is the original exception details.
Thanks for your help,
--Michael
"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:eRw9FzgiEHA.3632@TK2MSFTNGP09.phx.gbl...
> Statement: "It seems if I handle the error in my DAL"
> Question: Can you actually handle the error (like, hit a backup database, or
> hit a cache which might be stale but will give some information) or can you
> just swallow it?
>
> I ask because my guess is that you can't actually handle it at the DAL
> layer - all you can do is catch it at the presentation layer and display a
> friendly error message. At that point, you have two options:
>
> 1 - let the exception bubble up (either don't catch it, or have an empty
> throw (don't do a Throw ex))
> 2 - If, and only if, you can add additional information to the exception,
> rethrow a new exception (custom or not) making sure to include the original
> exception in there. (throw new ApplicationException("Doh",
> originalException))
>
> Karl
>
>
> "Raterus" <moc.liamtoh@suretar.reverse> wrote in message
> news:eQQaXmgiEHA.1040@TK2MSFTNGP09.phx.gbl...
> Hello,
>
> I'm trying to hop on the n-tier/OOP bandwagon for my applications, but I've
> hit one snag that I'm not sure the best way to proceed. Say a SqlException
> is raised in my Data Access layer, that is a long long way from my
> presentation layer/aspx page, where I would at least like to print out a
> notification that an error was raised. How can I best achieve this in an
> n-tier environment. It seems if I handle the error in my Data Access layer,
> by the time the code execution gets back to the presentation layer, it won't
> know what happened. Should I be defining my own object exceptions, and
> raise them when I catch an error, and let it propigate itself up the
> pipeline until the presentation layer can handle it?
>
> Any help would be greatly appreciated!
> --Michael
>
>
- Next message: Lerp: "Re: which is best method?"
- Previous message: Preserved Moose: "Using an ASP.NET page to send a file to the printer"
- In reply to: Karl: "Re: Handling Exceptions in an n-tier environment"
- Next in thread: Bryant Hankins: "Re: Handling Exceptions in an n-tier environment"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|