By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,320 Members | 2,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,320 IT Pros & Developers. It's quick & easy.

Exception Hanlding

P: n/a
tom
Hi,

I am developing a WinForm application and I am looking for a guide on where
to place Exception Handling. My application is designed into three tiers
UI, Business Objects, and Data Access Layer. My questions is where should I
put exception handling:

1) Should it be put in all significant methods in all layers?
2) Should I create an exception base class that will handle the errors and
pass useful error messages to the user?
3) Can I get away with just putting exception handling in the UI process
components which will then throw the error to the base class?

Thanks
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
MS has published some guidelines:

..NET Framework General Reference
Error Raising and Handling Guidelines
http://tinyurl.com/2opdo

--
Greetz,
Jan
__________________________________
Read my weblog: http://weblogs.asp.net/jan
"tom" <to*@cce.coom> schreef in bericht
news:Oy*************@TK2MSFTNGP10.phx.gbl...
Hi,

I am developing a WinForm application and I am looking for a guide on where to place Exception Handling. My application is designed into three tiers
UI, Business Objects, and Data Access Layer. My questions is where should I put exception handling:

1) Should it be put in all significant methods in all layers?
2) Should I create an exception base class that will handle the errors and
pass useful error messages to the user?
3) Can I get away with just putting exception handling in the UI process
components which will then throw the error to the base class?

Thanks

Nov 15 '05 #2

P: n/a
Hi tom,

"tom" <to*@cce.coom> wrote in message
news:Oy*************@TK2MSFTNGP10.phx.gbl...
Hi,

I am developing a WinForm application and I am looking for a guide on where to place Exception Handling. My application is designed into three tiers
UI, Business Objects, and Data Access Layer. My questions is where should I put exception handling:

1) Should it be put in all significant methods in all layers?
2) Should I create an exception base class that will handle the errors and
pass useful error messages to the user?
3) Can I get away with just putting exception handling in the UI process
components which will then throw the error to the base class?


Regarding exception handling in the Business Objects and Data Access
Layer:

1. If know you can recover gracefully from an exception, catch it
and deal with it.
2. If you can't (or don't want to) recover from the exception in
that layer, but there is some information you can pass up that's relevant to
the exception, catch the original exception and throw your custom exception.
Make sure to reference the original exception as the InnerException.
3. Otherwise, don't catch the exception

Regarding exception handling in the UI layer:
1. If you know you can recover from an exception, catch it and deal
with it. Display messages to the user as appropriate.
2. If you don't know how to handle an exception, don't catch it.
3. Optionally, attach an event handler to
Application.ThreadException to display a custom message to the user letting
them know something unexpected happened and maybe giving them some basic
options on what to do about it (continue, quit, send e-mail containing
exception info, etc.).

MS's Exception Management Block is useful for logging application
exceptions:
http://tinyurl.com/lhbd

My $0.02.

Regards,
Dan
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.