Пример #1
0
 public void OnError(string reporterName, Exception exception)
 {
     if (!ReportInformation.HasObservers)
     {
         return;
     }
     if (exception is AggregateException)
     {
         var exceptions = exception as AggregateException;
         foreach (var e in exceptions.InnerExceptions)
         {
             ReportExceptions.OnNext(new LogMessage <Exception>()
             {
                 Reporter = reporterName, Level = LogLevel.Error, Message = e
             });
         }
     }
     else
     {
         ReportExceptions.OnNext(new LogMessage <Exception>()
         {
             Reporter = reporterName, Level = LogLevel.Error, Message = exception
         });
     }
 }
Пример #2
0
 public void OnError(string reporterName, Exception innerException, string exceptionMessage, params object[] args)
 {
     ReportExceptions.OnNext(new LogMessage <Exception>()
     {
         Reporter = reporterName, Level = LogLevel.Error, Message = new Exception(String.Format(exceptionMessage, args), innerException)
     });
 }
Пример #3
0
        public IDisposable Chain <T>(IReactor <T> another) where T : IRxn
        {
            var resources = new CompositeDisposable();

            Input.Subscribe(e => another.Input.OnNext((T)e), e => ReportExceptions.OnNext(new LogMessage <Exception>()
            {
                Reporter = another.ReporterName, Level = LogLevel.Error, Message = e
            })).DisposedBy(resources);
            another.Output.Subscribe(r => Output.OnNext(r), e => ReportExceptions.OnNext(new LogMessage <Exception>()
            {
                Reporter = another.ReporterName, Level = LogLevel.Error, Message = e
            })).DisposedBy(resources);
            another.Errors.Subscribe(ReportExceptions).DisposedBy(_resources);//only report errors so we can see error state

            var health = AttachHealthMonitorIf(another);

            _molecules.Add(another);
            OnInformation("Chained to '{0}'", another.Name);

            return(new CompositeDisposable(resources, new DisposableAction(() =>
            {
                if (health != null)
                {
                    health.Dispose();
                }

                OnInformation("Unchained '{0}'", another.Name);
                _molecules.Remove(another);
            }))
                   .DisposedBy(_resources));
        }