Esempio n. 1
0
        public void Run(Action action)
        {
            Action wrapper = () => { catcher.Run(action); };

            //Invoke re-throws nested exception in caller thread
            //BeginInvoke throws nested exception in UI thread
            control.Invoke(wrapper);
        }
Esempio n. 2
0
        public void InstanceIgnoreTest()
        {
            var catcher = new Catcher();

            catcher.Run(
                () =>
            {
                throw new Exception("Error on Action!");
            }
                );
        }
Esempio n. 3
0
        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);
        }