Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

exception handling using enterprise library

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tester - 12 Oct 2007 23:02 GMT
I have an application that has a presentation later, business layer, and
data layer.  All three projects have their own exception policy, the "UI
Policy", "BL Policy", "DL Policy", all of which will log the error in the
application event logs.  When a database error occurs such as a missing
stored procedure, all three policies will log the event resulting in three
different entries in the error.  My boss says there is a way in the
exception handling to turn these duplicate errors off, but I certainly can't
find a way to do this.  And logically these are not duplicate errors, they
each use different policies and they each have a different stack recorded.
Every single procedure in every project has the exception code as follows:

               Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex,
"UI Exception Policy")
               If rethrow Then
                   throw
               End If

Until ultimately it gets back to the calling procedure, which also logs the
event, so we could have 5 million entries for one error.  Okay, slight
exaggeration.

My thought is we need to be more precise on how we handle these errors.  The
data layer is always bubbled up,  so I wouldn't think we'd need the data
layer errors, since the ui layer will.  What is the proper way to do this?
Some example code:

Presentation Layer:
   Sub TestDatabaseConnection
try
       Dim bl as new bl
       Dim ds as new Dataset
       ds = bl.UpdateData(connString, spUpdateStuff)
Catch ex as exception
               Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex,
"UI Exception Policy")
               If rethrow Then
                   throw
               End If
end try

   end sub

Business Layer (bl)
   function UpdateData(connString, sp) as integer
       Dim dl as new dl
       return dl.ExecuteNonquery(connString, sp)
Catch ex as exception
               Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex,
"BL Exception Policy")
               If rethrow Then
                   throw
               End If
end try
   end function

Data Layer (dl)
   function ExecuteNonQuery(connString, sp) as integer
       try
              Dim retval as integer
              retval = SqlDataAccess.ExecuteNonQuery(connString,
commandtype.storedprocedure, sp)
           return retval
Catch ex as exception
               Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex,
"DL Exception Policy")
               If rethrow Then
                   throw
               End If
end try

end fundtion
Alvin Bruney [MVP] - 14 Oct 2007 02:29 GMT
The idea is to always log at every level. In production, logging is usually
turned off unless there is a problem. At this point, logging is turned on
and trouble-shooting is easier with 5 million logged messages. Then, turn it
back off.

Signature

Regards,
Alvin Bruney
------------------------------------------------------
Shameless Author Plug
OWC Black Book 2nd Edition
Exclusively on www.lulu.com/owc
$24.99

>I have an application that has a presentation later, business layer, and
>data layer.  All three projects have their own exception policy, the "UI
[quoted text clipped - 68 lines]
>
> end fundtion

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.