* csharper <>:
> First of all, exception messages are not even designed to be seen by
> the end users (am I right?), why display it in the web form? Do you
> people out there agree? I am still learning, so please correct me if
> I am wrong.
Well, exceptions are for error conditions, they should never be used for
normal program flow. And, displaying error messages to the user IS
normal program flow. So, you're right. Just a little thing: exceptions
should be seen by the end user in case they are unhandled, so he can
give a meaningful bug report
> Secondly, I find myself quickly out of hands if I have to handle
> exceptions on such a fine-granulated resolution (i.e., in each method
> where certain kinds of exceptions can potentially be thrown).
> Wouldn't it be better to let the exception propagates and handle it in
> some centralized location such as global.asax?
Uhm, no, not necessarily. You can't handle any exception in a
centralized location, that would require knowledge about any execution
path of the whole application in THAT location.
Handle exceptions that you CAN handle close to where they occur, let
those you can't handle propagate. Optionally create some centralized
exception handler that for example triggers a bug reporting
functionality. Of course, handling an exception does NOT mean displaying
it to the user. If there's some expected user error, try to handle it
without throwing an exception in the first place. Typically for parsing
user input, you want to use the various "TryParse()" methods provided by
the framework. (Custom) validators can help, too.
Regards,
Felix
--
Felix Palmen (Zirias) + [PGP] Felix Palmen <>
web:
http://palmen-it.de/ |
http://palmen-it.de/pub.txt
my open source projects: | Fingerprint: ED9B 62D0 BE39 32F9 2488
http://palmen-it.de/?pg=pro + 5D0C 8177 9D80 5ECF F683