Re: Handling Exceptions in an n-tier environment

From: Karl (_at_)
Date: 08/24/04


Date: Tue, 24 Aug 2004 15:06:45 -0400

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



Relevant Pages

  • Re: Handling Exceptions in an n-tier environment
    ... I can understand creating a new ApplicationException with additional details, but sometimes all I need is the original exception details. ... > hit a cache which might be stale but will give some information) or can you ... > originalException)) ... > by the time the code execution gets back to the presentation layer, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Problem with installing KB832880
    ... An exception was hit while trying to log a message. ... PreRequisite ... Die Installation des KB832880 wurde nicht abgeschlossen. ...
    (microsoft.public.windows.server.sbs)
  • Re: [RFC Patch 3/9] Modifying generic debug exception to use virtual debug registers
    ... The remaining cntents of the DR6 register are never cleared by the processor." ... generated for the exception. ... I don't think kprobes should "take care of" DR_STEP. ... hit and a single-step, with DR_STEP plus DR_TRAPn both set at once. ...
    (Linux-Kernel)
  • Re: perf & Try Catch
    ... Throwing the exception is definitely of much more concern and where you ... should be concerned -- but you can wrap away - no hit there whatsoever. ... > try-catch instead of using a try-catch inside the loop. ... There is also a> small perf hit in the catch block when the exception is caught because the> runtime must examine each catch handler to determine if it is suitable to ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: perf & Try Catch
    ... execution time is increased by 39 percent. ... I can see why there'd be a onetime perf hit due to the extra ... The cost of the exception itself only occurs when it is ...
    (microsoft.public.dotnet.languages.csharp)