Пример #1
0
 /// <summary>
 /// Runs the task asynchronously and
 /// adds an error annotation in case of failure
 /// </summary>
 /// <param name="trace"></param>
 /// <param name="task"></param>
 public static async Task TracedActionAsync(this BaseStandardTrace trace, Task task)
 {
     try
     {
         await task;
     }
     catch (Exception ex)
     {
         trace?.Error(ex);
         throw;
     }
 }
Пример #2
0
 /// <summary>
 /// Runs the task asynchronously with custom return type and
 /// adds an error annotation in case of failure
 /// </summary>
 /// <param name="trace"></param>
 /// <param name="task"></param>
 public static async Task <T> TracedActionAsync <T>(this BaseStandardTrace trace, Task <T> task)
 {
     try
     {
         return(await task);
     }
     catch (Exception ex)
     {
         trace?.Error(ex);
         throw;
     }
 }