Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > exception handling using enterprise library

Reply
Thread Tools

exception handling using enterprise library

 
 
Guest
Posts: n/a
 
      10-12-2007
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



 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      10-14-2007
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.

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


<tester> wrote in message news:(E-Mail Removed)...
>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
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET Exception Handling with the Enterprise Library (Jan 2006) Wade ASP .Net 3 07-25-2006 05:20 AM
Enterprise Library Jan 2006 - custom exception formatter fails unless running debugger David Herbst ASP .Net 1 01-29-2006 04:02 PM
Security Exception with Enterprise Library Data Block Jonathan Crawford ASP .Net 6 12-11-2005 05:31 PM
Enterprise Library: Exception Handling Block - how do I get to HandlingInstanceID? levon ASP .Net 0 09-28-2005 12:25 AM
handlingInstanceID in Enterprise Library Exception Block =?Utf-8?B?QWhzYW4=?= ASP .Net 0 03-31-2005 02:43 PM



Advertisments