public virtual void UncaughtException(Sharpen.Thread t, Exception e)
 {
     if (ShutdownHookManager.Get().IsShutdownInProgress())
     {
         Log.Error("Thread " + t + " threw an Throwable, but we are shutting " + "down, so ignoring this"
                   , e);
     }
     else
     {
         if (e is Error)
         {
             try
             {
                 Log.Fatal("Thread " + t + " threw an Error.  Shutting down now...", e);
             }
             catch
             {
             }
             //We don't want to not exit because of an issue with logging
             if (e is OutOfMemoryException)
             {
                 //After catching an OOM java says it is undefined behavior, so don't
                 //even try to clean up or we can get stuck on shutdown.
                 try
                 {
                     System.Console.Error.WriteLine("Halting due to Out Of Memory Error...");
                 }
                 catch
                 {
                 }
                 //Again we done want to exit because of logging issues.
                 ExitUtil.Halt(-1);
             }
             else
             {
                 ExitUtil.Terminate(-1);
             }
         }
         else
         {
             Log.Error("Thread " + t + " threw an Exception.", e);
         }
     }
 }