473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Exception Management contradiction

Hello,

I am currently in the process of switching our application to a N-Tier model
with .NET.

One of the aspects we want ot get right from the start not to worry about it
after is the Exception management.

I have read two MSDN documents that appear to be in contradiction, and I
would like to know if someone can explain to me which of the two is the
recommended approach.

The documents are "Exception Management in .NET" and "Application
Architecure for .NET: Designing Applications and Serivces."

In general, the contradiction I found lies in how to handle the logging and
notification tasks when managing unhandled exceptions.

The first document "Exception Management in .NET" recommends to perform
logging and notifications right before displaying the exception information
to the user:
"When an unhandled exception propagates to the last point or boundary at
which your application can the handle exception before returning to the user,
your application can no longer recover from the exception. At this point, it
mus gather information, log information, send any notifications, ...."
"In most Web-based applications, this boundary is controlled by your ASP.NET
code..." (from page 13)
Then it goes to explain different mechanism availabel in ASP.NET to handle
exceptions.
It also states: "An exception management system should be well encapsulated
and should abstract the details of logging and reporting from the
application's business logic." (from page 1)

This is all fine and makes sense, exceptions are handle and propagated in
all layers of the application, and the UI takes care of logging, notifying
and ultimately displaying the relevant information.

But the, I found something in "Application Architecture for .NET: Designing
Applications and Services" that makes me wonder if I am getting it wrong.
It mentions hwo exception management should be achieved at each layer.
UI Components:
"User Interface componnents should publish their exceptions ... It is common
to publish to some central server and/or local file or event log."
(so far this is just dandy, it goes along with the first document)

Business Components:
"Exceptions should be publish in business layers, because this is where
transaction outcome is known and internal serice level agreement are defined."
(Are we talking about logging and notifying? this does not sound in
accordance with the first document. What about the "boundary before returning
to the user" ?)

Data Access Components:
"Data Access Components should always publish their exceptions by writing
exception details to a log file ..."
(Now I am confused)

I really dont mind which one of the two is correct, personally, the first
document makes more sense to me (but this post is long enough as it is to go
into that.)

What I really would like to know is which of the two approaches is the
recommended and if there is an explanation for this contradiction ?

Thanks in advance

Jul 21 '05 #1
1 1815
I don't see a contradiction.

The first article is discussing unhandled exceptions. These are exceptions
that you did not expect.
The second article is discussing where to put exception handling for
exceptions that you would expect would occur. These would be "handled"
exceptions.

My rule of thumb: keep exception handling as close to the code that created
the exception as you can. Have business objects respond in a sensible
manner when exceptions occur. Build the exception behavior into the
behavior of the object. (e.g. if you tell a business object to "go get
data", it should use a data accessor object that understands how to respond
when the database connection is lost. On the other hand, credentials issues
would have to "bubble up" since the business object layer cannot handle that
exception any better than the data access layer could... it's up the user to
provide credentials).

Good Luck,
--- Nick

"Abelardo Vacca" <Ab***********@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
Hello,

I am currently in the process of switching our application to a N-Tier model with .NET.

One of the aspects we want ot get right from the start not to worry about it after is the Exception management.

I have read two MSDN documents that appear to be in contradiction, and I
would like to know if someone can explain to me which of the two is the
recommended approach.

The documents are "Exception Management in .NET" and "Application
Architecure for .NET: Designing Applications and Serivces."

In general, the contradiction I found lies in how to handle the logging and notification tasks when managing unhandled exceptions.

The first document "Exception Management in .NET" recommends to perform
logging and notifications right before displaying the exception information to the user:
"When an unhandled exception propagates to the last point or boundary at
which your application can the handle exception before returning to the user, your application can no longer recover from the exception. At this point, it mus gather information, log information, send any notifications, ...."
"In most Web-based applications, this boundary is controlled by your ASP.NET code..." (from page 13)
Then it goes to explain different mechanism availabel in ASP.NET to handle
exceptions.
It also states: "An exception management system should be well encapsulated and should abstract the details of logging and reporting from the
application's business logic." (from page 1)

This is all fine and makes sense, exceptions are handle and propagated in
all layers of the application, and the UI takes care of logging, notifying
and ultimately displaying the relevant information.

But the, I found something in "Application Architecture for .NET: Designing Applications and Services" that makes me wonder if I am getting it wrong.
It mentions hwo exception management should be achieved at each layer.
UI Components:
"User Interface componnents should publish their exceptions ... It is common to publish to some central server and/or local file or event log."
(so far this is just dandy, it goes along with the first document)

Business Components:
"Exceptions should be publish in business layers, because this is where
transaction outcome is known and internal serice level agreement are defined." (Are we talking about logging and notifying? this does not sound in
accordance with the first document. What about the "boundary before returning to the user" ?)

Data Access Components:
"Data Access Components should always publish their exceptions by writing
exception details to a log file ..."
(Now I am confused)

I really dont mind which one of the two is correct, personally, the first
document makes more sense to me (but this post is long enough as it is to go into that.)

What I really would like to know is which of the two approaches is the
recommended and if there is an explanation for this contradiction ?

Thanks in advance

Jul 21 '05 #2

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

Similar topics

1
by: Steve O'maley | last post by:
I currently have the Exception Management Application Block working in my base directory, but when I create pages in a subfolder the Exception Management Application Block is never executed. The...
1
by: Andy | last post by:
Hi All, I'm basically just trying to get started with the Exception Management Application Block and am having some technical difficulties. All I want to do to begin with is create a simple...
6
by: Páll Ólafsson | last post by:
Hi I have a problem with the Microsoft.ApplicationBlocks.ExceptionManagement? I can't get it to work in RELEASE mode? If I run the project in debug mode the block works fine but when I run the...
5
by: PCC | last post by:
I am using the Exception Managment Application Block on Windows Server 2003 Enterprise and .NET v1.1. If I use the block with an ASP.NET web wervice or in a web application I get the following...
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
1
by: Abelardo Vacca | last post by:
Hello, I am currently in the process of switching our application to a N-Tier model with .NET. One of the aspects we want ot get right from the start not to worry about it after is the...
1
by: SQLJunkie | last post by:
Hi, I have installed SQL 2005 RTM on a new server and I keep getting this error (described below) quite frequently. Was wondering if anyone has a clue on what's happening here. I tried googling...
2
by: KaNos | last post by:
Hello world, I've made a webservice (c# v2) to install in a server IIS 6 on a Windows 2000 last SP. We can use the webservice in local, throw the pages wich present the methods, with a windows...
1
by: =?Utf-8?B?QnJldHQgT3NzbWFu?= | last post by:
I'm trying to set up a custome e-mail publisher for a web app using the Microsoft Exception Management Application Block for .NET sample app. Our app already uses the Exception Management Block,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.