Ignore:
Timestamp:
Mar 29, 2011, 7:34:41 AM (13 years ago)
Author:
Sam Habiel
Message:

Added (maybe) better uncaught Exception handling. We'll see if it works at all.
Release exes, again.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Scheduling/trunk/cs/bsdx0200GUISourceCode/CGDocumentManager.cs

    r1121 r1122  
    186186        static void Main(string[] args)
    187187        {
     188            //Application wide error handler for unhandled errors (later I figure out that's only for WinForm ex'es)
     189            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);
     190            Application.ThreadException += new ThreadExceptionEventHandler(App_ThreadException);
     191
     192            // Add the event handler for handling non-UI thread exceptions to the event.
     193            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(App_DomainException);
     194
    188195#if DEBUG
    189196            // Print console messages to console if launched from console
     
    231238            Application.DoEvents();
    232239
    233             //Application wide error handler for unhandled errors
    234             Application.ThreadException += new ThreadExceptionEventHandler(App_ThreadException);
     240            //test
     241            //doc.ThrowException();
     242            //test
    235243
    236244#if TRACE
     
    247255
    248256        /// <summary>
    249         /// Exception handler for application errors. TODO: Test
    250         /// </summary>
     257        /// Exception handler for application errors. Only for WinForm Errors.
     258        /// </summary>
     259        /// <remarks>Never tested. I can't get an error to go here!</remarks>
    251260        /// <param name="sender"></param>
    252261        /// <param name="e"></param>
    253262        static void App_ThreadException(object sender, ThreadExceptionEventArgs e)
    254263        {
    255             if (e.Exception is System.Net.Sockets.SocketException)
    256             {
    257                 MessageBox.Show("Looks like we lost our connection with the server\nClick OK to terminate the application.");
    258                 Application.Exit();
    259             }
    260 
    261264            string msg = "A problem has occured in this applicaton. \r\n\r\n" +
    262265                "\t" + e.Exception.Message + "\r\n\r\n" +
     
    269272        }
    270273
     274        /// <summary>
     275        /// If we are here, we are dead meat.
     276        /// </summary>
     277        /// <param name="sender"></param>
     278        /// <param name="e"></param>
     279        static void App_DomainException(object sender, UnhandledExceptionEventArgs e)
     280        {
     281            if (e.ExceptionObject is System.Net.Sockets.SocketException)
     282            {
     283                MessageBox.Show("Looks like we lost our connection with the server\nClick OK to terminate the application.");
     284            }
     285            else
     286            {
     287                Exception ex = e.ExceptionObject as Exception;
     288
     289                string msg = "A problem has occured in this applicaton. \r\n\r\n" +
     290                    "\t" + ex.InnerException.Message;
     291
     292                MessageBox.Show(msg, "Unexpected Error");
     293            }
     294        }// here application terminates
    271295
    272296        #region BMXNet Event Handler
Note: See TracChangeset for help on using the changeset viewer.