I've caught an exception!! Now what?

后端 未结 16 931
逝去的感伤
逝去的感伤 2021-02-02 05:15

I\'ve started using try-catch blocks (a bit late, I know!), but now I\'m not sure what to do with the exception once I\'ve caught it. What should I do?



        
16条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-02 05:44

    Depending on the type of application, consider either a global logging handler (i.e. 'Application_Error' for ASP.NET applications) or using a pre-built open source or MSFT provided exception handling framework.

    The Exception Handling Application Block as part of the Enterprise Library 5.0 is a suggested framework to use.

    Aside from logging, I agree that exceptions need not be explicitly caught unless you need to do something meaningful with them. And the worst mistake is just to 'Catch' and then 'Throw' again as this messes the StackTrace up.

提交回复
热议问题