public override async Task HandleAsync(ExceptionNotificationContext context) { if (context.Handled && Options.HasNotifierError(context.Exception)) { using (var scope = ServiceScopeFactory.CreateScope()) { await SendErrorNotifierAsync( new ExceptionSendNotifierContext(scope.ServiceProvider, context.Exception, context.LogLevel)); } } }
/// <summary> /// notify as an asynchronous operation. /// </summary> /// <param name="context">The context.</param> /// <returns>Task.</returns> public virtual async Task NotifyAsync([NotNull] ExceptionNotificationContext context) { Check.NotNull(context, nameof(context)); using (var scope = ServiceScopeFactory.CreateScope()) { var exceptionSubscribers = scope.ServiceProvider .GetServices <IExceptionSubscriber>(); foreach (var exceptionSubscriber in exceptionSubscribers) { try { await exceptionSubscriber.HandleAsync(context); } catch (Exception e) { Logger.LogWarning($"Exception subscriber of type {exceptionSubscriber.GetType().AssemblyQualifiedName} has thrown an exception!"); Logger.LogException(e, LogLevel.Warning); } } } }
public Task NotifyAsync(ExceptionNotificationContext context) { return(Task.CompletedTask); }
public abstract Task HandleAsync(ExceptionNotificationContext context);