Example #1
0
    public void ShouldHandleFatalException()
    {
        var causeException = new Exception();
        var evt            = new StubEvent(0);

        var exceptionHandler = new FatalExceptionHandler <StubEvent>();

        var exception = Assert.Throws <ApplicationException>(() => exceptionHandler.HandleEventException(causeException, 0L, evt));

        Assert.IsNotNull(exception);
        Assert.AreEqual(causeException, exception !.InnerException);
    }
Example #2
0
    static void FatalExceptionObject(object exceptionObject)
    {
        var huh = exceptionObject as Exception;

        if (huh == null)
        {
            huh = new NotSupportedException(
                "Unhandled exception doesn't derive from System.Exception: "
                + exceptionObject.ToString()
                );
        }
        FatalExceptionHandler.Handle(huh);
    }
Example #3
0
 static void Main(string[] argv)
 {
     try
     {
         AppDomain.CurrentDomain.UnhandledException += (sender, e) => FatalExceptionHandler.Handle((Exception)e.ExceptionObject);
         Application.ThreadException += (sender, e) => FatalExceptionHandler.Handle(e.Exception);
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         // whatever you need/want here
         Application.Run(new MainWindow());
     }
     catch (Exception huh)
     {
         FatalExceptionHandler.Handle(huh);
     }
 }
Example #4
0
        public void ShouldHandleFatalException()
        {
            var causeException = new Exception();
            var evt            = new StubEvent(0);

            var exceptionHandler = new FatalExceptionHandler();

            try
            {
                exceptionHandler.HandleEventException(causeException, 0L, evt);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(causeException, ex.InnerException);
            }
        }
Example #5
0
 static void Main(string[] argv)
 {
     try
     {
         AppDomain.CurrentDomain.UnhandledException += (sender, e)
                                                       => FatalExceptionObject(e.ExceptionObject);
         Application.ThreadException += (sender, e)
                                        => FatalExceptionHandler.Handle(e.Exception);
         // whatever you need/want here
         Application.Run(new MainWindow());
     }
     catch (Exception huh)
     {
         FatalExceptionHandler.Handle(huh);
     }
 }
        public void ShouldHandleFatalException()
        {
            var causeException = new Exception();
            var evt = new StubEvent(0);

            var exceptionHandler = new FatalExceptionHandler();

            try
            {
                exceptionHandler.HandleEventException(causeException, 0L, evt);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(causeException, ex.InnerException);
            }
        }
Example #7
0
        public void ShouldHandleFatalException()
        {
            Exception causeException = new Exception();
            Entry     entry          = new TestEntry();

            ILog logger = _mocks.DynamicMock <ILog>();

            Expect.Call(() => logger.Fatal("Exception processing: " + entry, causeException));
            _mocks.ReplayAll();

            IExceptionHandler exceptionHandler = new FatalExceptionHandler(logger);

            try
            {
                exceptionHandler.Handle(causeException, entry);
                Assert.Fail("No exception was thrown");
            }
            catch (ApplicationException ex)
            {
                Assert.AreEqual(causeException, ex.InnerException);
            }

            _mocks.VerifyAll();
        }
	    public void ShouldHandleFatalException()
	    {
	        Exception causeException = new Exception();
	        Entry entry = new TestEntry();
	
	        ILog logger = _mocks.DynamicMock<ILog>();
	        
	        Expect.Call(() => logger.Fatal("Exception processing: " + entry, causeException));
            _mocks.ReplayAll();
	        
	        IExceptionHandler exceptionHandler = new FatalExceptionHandler(logger);
	
	        try
	        {
	            exceptionHandler.Handle(causeException, entry);
	            Assert.Fail("No exception was thrown");
	        }
	        catch (ApplicationException ex)
	        {
	            Assert.AreEqual(causeException, ex.InnerException);
	        }
	        
	        _mocks.VerifyAll();
	    }