Should I catch all my exceptions in global.asax?

If I simply log the details of the exception in my web application, do I really need to put the exception handling logic for each level? Why not just let them pop up the stack trace on global.asax and register them there?

+3
source share
5 answers

I would suggest against using any exception handling logic at any level of your application if:

  • The exception is not fatal, it means that there are some actions that you can take to restore, or
  • The application must continue to function, and the exception must be "ignored." Example: when registering in the online store, you will receive a receipt by e-mail. If this fails - but another order processing product succeeds - the user should not display the error page. Here we want the workflow to continue, although there is an exception. Most exceptions do not fall into this category.

, - , "" , . Application.Error. , Global.asax, , HTTP-, ELMAH.

, - - ASP.NET, :

ASP.NET :

(a) .

(b) , . ASP.NET. , , :

  • , ,

  • , , .

(c) - ( - ), . ELMAH ASP.NET .

+5

, , . , .

Application.Error - , / , , / .

+2

, , , " " " ".

, , .

, , - , . , , , , .

, , , - , .

+1

... , , , , , .. Elmah .

, , , . , , , -, 1 500 .

0

Source: https://habr.com/ru/post/1777527/


All Articles