473,594 Members | 2,757 Online
Bytes | Software Development & Data Engineering Community
+ 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 .HandleExceptio n(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 TestDatabaseCon nection
try
Dim bl as new bl
Dim ds as new Dataset
ds = bl.UpdateData(c onnString, spUpdateStuff)
Catch ex as exception
Dim rethrow As Boolean = ExceptionPolicy .HandleExceptio n(ex,
"UI Exception Policy")
If rethrow Then
throw
End If
end try

end sub

Business Layer (bl)
function UpdateData(conn String, sp) as integer
Dim dl as new dl
return dl.ExecuteNonqu ery(connString, sp)
Catch ex as exception
Dim rethrow As Boolean = ExceptionPolicy .HandleExceptio n(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.E xecuteNonQuery( connString,
commandtype.sto redprocedure, sp)
return retval
Catch ex as exception
Dim rethrow As Boolean = ExceptionPolicy .HandleExceptio n(ex,
"DL Exception Policy")
If rethrow Then
throw
End If
end try

end fundtion

Oct 12 '07 #1
1 2482
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******** ******@TK2MSFTN GP03.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 .HandleExceptio n(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 TestDatabaseCon nection
try
Dim bl as new bl
Dim ds as new Dataset
ds = bl.UpdateData(c onnString, spUpdateStuff)
Catch ex as exception
Dim rethrow As Boolean =
ExceptionPolicy .HandleExceptio n(ex, "UI Exception Policy")
If rethrow Then
throw
End If
end try

end sub

Business Layer (bl)
function UpdateData(conn String, sp) as integer
Dim dl as new dl
return dl.ExecuteNonqu ery(connString, sp)
Catch ex as exception
Dim rethrow As Boolean =
ExceptionPolicy .HandleExceptio n(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.E xecuteNonQuery( connString,
commandtype.sto redprocedure, sp)
return retval
Catch ex as exception
Dim rethrow As Boolean =
ExceptionPolicy .HandleExceptio n(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
2332
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 assemblies are loaded before shutting down. In one case, some of my DB-accessing code didn't handle a NULL value properly. But try...catch wouldn't catch the exception and keep going. I'd just get the error message and then it would shut the...
1
262
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 Faults:0)) 2) Buiness Rules Exceptions.I just wondered if someone could introduce me a refernce or link from which I can get some idea on how to adopt a robust and good exception handling mechanism for our scenario. Thanks alot
1
4130
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. When I attached the debugger to the process and stepped into the code it executed without error. In both cases I was running a Debug build, the only difference in the case that works is that I attached the debugger to the same exact binaries....
16
2532
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 method: // --- Create an Exception Handler for Thread Exceptions ---------------- Application.ThreadException += new ThreadExceptionEventHandler(OnThreadException);
3
1384
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 user (AppMessageExceptionHandler.cs, line 51). How should this be done in ASP.NET? We have a control defined on our pages that we want errors to output into .... how should we accomplish this? Since our exception handler is in our business...
3
1265
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 itself... What would be the best Approach ?
1
1453
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 action ( for example add a item in the database). The last class is the one who conect to the DB ( ms access) How I should manage an exception ? * What I must do when an exception occurs when the class number 3 wants to make a DB coneection an...
0
2528
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. I created a project and added the following references - 1/ Enterprise Library Exception Handling Application Block v 4.0
0
2185
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 VB.Net (Visual Studio 2005) which have three tiers: User Interface Business Logic Data Layer
0
7947
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7880
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8374
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8010
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8242
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6665
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5413
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
1486
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.