How can I avoid duplicated try catch blocks

后端 未结 4 1067
我在风中等你
我在风中等你 2021-02-08 06:18

I have several methods that look like this:

public void foo()
{
   try 
   {
      doSomething();
   }
   catch(Exception e)
   {
      Log.Error(e);
   }
 }
         


        
4条回答
  •  别那么骄傲
    2021-02-08 07:05

    You may try using: PostSharp

    or try to google 'AOP' - 'Aspect Oriented Programming'. There are more similar techniques on the web.

提交回复
热议问题