Why catch and rethrow an exception in C#?

前端 未结 17 908
遥遥无期
遥遥无期 2020-11-22 14:56

I\'m looking at the article C# - Data Transfer Object on serializable DTOs.

The article includes this piece of code:

public static string Se         


        
17条回答
  •  野性不改
    2020-11-22 15:25

    Most of answers talking about scenario catch-log-rethrow.

    Instead of writing it in your code consider to use AOP, in particular Postsharp.Diagnostic.Toolkit with OnExceptionOptions IncludeParameterValue and IncludeThisArgument

提交回复
热议问题