Esempio n. 1
0
 /// <summary>
 /// Marks the specified <see cref="IPromise"/> as failure. If the
 /// <see cref="IPromise"/> is done already, log a message.
 /// </summary>
 /// <param name="promise">The <see cref="IPromise"/> to complete.</param>
 /// <param name="cause">The <see cref="Exception"/> to fail the <see cref="IPromise"/> with.</param>
 /// <param name="logger">The <see cref="IInternalLogger"/> to use to log a failure message.</param>
 public static void SafeSetFailure(IPromise promise, Exception cause, IInternalLogger logger)
 {
     if (!promise.IsVoid && !promise.TrySetException(cause) && logger.WarnEnabled)
     {
         var err = promise.Task.Exception?.InnerException;
         if (err is null)
         {
             logger.FailedToMarkAPromiseAsFailure(promise, cause);
         }
         else
         {
             logger.FailedToMarkAPromiseAsFailureFailed(promise, cause, err);
         }
     }
 }