472,145 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Exception Hanlding

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
2 2491
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
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.

Similar topics

4 posts views Thread by Nicolas Fleury | last post: by
2 posts views Thread by cody | last post: by
1 post views Thread by Old Wolf | last post: by
3 posts views Thread by Franz | last post: by
44 posts views Thread by craig | last post: by
3 posts views Thread by JohnDeHope3 | last post: by
10 posts views Thread by dinopc | last post: by
reply views Thread by leo001 | last post: by

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.