473,473 Members | 1,955 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

exception handling using enterprise library

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

Oct 12 '07 #1
1 2477
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
<testerwrote in message news:OM**************@TK2MSFTNGP03.phx.gbl...
>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

Oct 14 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Daniel Wilson | last post by:
I am having exception-handling and stability problems with .NET. I will have a block of managed code inside try...catch and will still get a generic ..NET exception box that will tell me which...
1
by: Ray5531 | last post by:
We are developing an ASP.NET application which has a UI a business layer and a OR Mapper generated DAL layer.We have two types of Exceptions that might occure 1) Runtime Exceptions (Programmer...
1
by: David Herbst | last post by:
Enterprise Library Jan 2006 with Visual Studio 2005 on Windows 2000 Server sp4. My custom exception formatter fails with a "Unable to handle exception: 'LoggingExceptionHandler'." exception. ...
16
by: Chuck Cobb | last post by:
I'm implementing a centralized exception handling routine using the Enterprise Library Exception Management Application Block. I trap all unhandled exceptions to one place using the following...
3
by: Wade | last post by:
Hey all, Question regarding Exception Handling w/ Application Blocks. The example given (ExceptionHandlingWithLogginQuickStart) creates a DialogResult to display the error message back to the...
3
by: Bruce One | last post by:
I am developing a new project in which we should have a good Exception Handling. Ive seen there is a Exception Handling App Block in Enterprise Library, also I could use the Try-Catch structure...
1
by: Jarsinio | last post by:
I have some doubts about how managed exception in a VB.net aplication. In my aplicattion I have 3 clases: One clase is the UI ( Windows Forms). This class call a second clase who perform an...
0
by: =?Utf-8?B?UG9sbHkgQW5uYQ==?= | last post by:
Hi, I have previously used EL v 3.1 Exception Handling application block successfully. I thought I would now try to do the same with EL v 4.0. My first experiment was to replace an exception....
0
by: srizzler | last post by:
Hi All: I am trying to implement Exception Handling using Enterprise Library 3.1's Exception Handling Application Block as well as Logging Blocks. I have a windows application developed in...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.