public void Dispose() { while (actions.Count > 0) { Catcher.Try(actions.Pop()); } }
public void StaticIgnoreTest() { Catcher.Try( () => { throw new Exception("Error on Action!"); } ); }
public void InstanceIgnoreTest() { var catcher = new Catcher(); catcher.Run( () => { throw new Exception("Error on Action!"); } ); }
public void StaticHandleTest() { var exceptions = new List <Exception>(); Catcher.Try( () => { throw new Exception("Error on Action!"); }, (ex) => { exceptions.Add(ex); throw new Exception("Error on Handler!"); } ); Assert.AreEqual(1, exceptions.Count); Assert.AreEqual("Error on Action!", exceptions[0].Message); }
private void Loop() { while (!disposed) { if (idle == null) { var action = idle; lock (queue) { if (queue.Count == 0) { Monitor.Wait(queue); } if (queue.Count > 0) { action = queue.Dequeue(); } } if (action != null) { Catcher.Try(action, catcher); } } else { var action = idle; lock (queue) { if (queue.Count > 0) { action = queue.Dequeue(); } } Catcher.Try(action, catcher); } } }
public void Log(Log log) { formatter.Format(log); runner.Run(() => { foreach (var appender in appenders) { Catcher.Try(() => appender(log), (ex) => { removes.Add(appender); Thrower.Dump(ex); }); } //autoremove excepting appenders foreach (var appender in removes) { appenders.Remove(appender); } removes.Clear(); }); }
public void InstanceHandleTest() { var exceptions = new List <Exception>(); var catcher = new Catcher( (ex) => { exceptions.Add(ex); throw new Exception("Error on Handler!"); } ); catcher.Run( () => { throw new Exception("Error on Action!"); } ); Assert.AreEqual(1, exceptions.Count); Assert.AreEqual("Error on Action!", exceptions[0].Message); }
public ControlRunner(Control control, Action <Exception> catcher = null) { this.control = control; this.catcher = new Catcher(catcher); }
public static void Dispose(IDisposable disposable) { Catcher.Try(() => { disposable?.Dispose(); }); }