Share Pastebin
Guest
Public paste!

PlatformerExpandedError

By: a guest | Jun 27th, 2009 | Syntax: C# | Size: 1.80 KB | Hits: 131 | Expires: Never
Copy text to clipboard
  1. using System;
  2. using ErrorReporter;
  3.  
  4. namespace Platformer_Expanded
  5. {
  6.     static class Program
  7.     {
  8.         static bool debugging = false;
  9.  
  10.         // TO FORCE THE ERROR ENGINE TO BELIEVE IT ISNT IN DEBUG MODE, CHANGE THE VARIABLE BELOW TO TRUE
  11.         static bool manualdebugdisable = true;
  12.         /// <summary>
  13.         /// The main entry point for the application.
  14.         /// </summary>
  15.         static void Main(string[] args)
  16.         {
  17.  
  18.  
  19. #if DEBUG
  20.             if (!manualdebugdisable && System.Diagnostics.Debugger.IsAttached)
  21.             {
  22.                 debugging = true;
  23.             }
  24. #endif
  25.  
  26.  
  27.  
  28.             if (debugging)
  29.             {
  30.  
  31.                 using (PlatformerGame game = new PlatformerGame())
  32.                 {
  33.                     game.Run();
  34.                 }
  35.             }
  36.             else
  37.             {
  38.                 while (true)
  39.                 {
  40.                     try
  41.                     {
  42.                         using (PlatformerGame game = new PlatformerGame())
  43.                         {
  44.                             game.Run();
  45.                             break;
  46.                         }
  47.                     }
  48.                     catch (Exception e)
  49.                     {
  50.                         try
  51.                         {
  52.                             using (ErrorReporter.ErrorReporter err = new ErrorReporter.ErrorReporter(e))
  53.                             {
  54.                                 err.RestartEnabled = true;
  55.                                 err.Run();
  56.                             }
  57.                         }
  58.                         catch (RestartNeededException)
  59.                         {
  60.                             Main(null);
  61.                         }
  62.  
  63.                     }
  64.                 }
  65.             }
  66.         }
  67.     }
  68. }