C
csharper
I am working on an existing asp.net web application.
I see a lot of try catch blocks in the code behind and the exception
message is displayed through a label control in the web form. A lot
of them are simply
lblErrorMessage.Text = ex.Message;
I am concerned about such an exception handling strategy.
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.
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?
Please share your advice on the best practices of exception handling
in an asp.net web application. I'll more questions with regard to
logging.
Thank you very much.
I see a lot of try catch blocks in the code behind and the exception
message is displayed through a label control in the web form. A lot
of them are simply
lblErrorMessage.Text = ex.Message;
I am concerned about such an exception handling strategy.
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.
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?
Please share your advice on the best practices of exception handling
in an asp.net web application. I'll more questions with regard to
logging.
Thank you very much.