using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Error_System { class Program { static void Main(string[] args) { // Error mode constants const int EM_SAVE = 1; const int EM_MESSAGE_BOX = 2; const int EM_EXCEPTION = 3; // MESSAGE BOX MODE // Enabled by default Console.WriteLine(); Console.WriteLine("Message box mode"); mn.DNS("ERROR"); // Cause error (mnStart needs to be used before mnDNS) // SAVE MODE Console.WriteLine(); Console.WriteLine("Save mode"); mn.ToggleErrorMode(EM_MESSAGE_BOX); // Disable error message boxes mn.ToggleErrorMode(EM_SAVE); // Enable save mode mn.DNS("ERROR"); // Cause error // mnGetErrorFlag or the return value can be used // to determine if an error has occurred. mnGetErrorFlag // overcomes the problem that some commands return different // values upon error if(mn.GetErrorFlag() == true) { Console.WriteLine("An error occurred whilst " + mn.GetErrorOperation()); } // EXCEPTION MODE Console.WriteLine(); Console.WriteLine("Exception mode"); mn.ToggleErrorMode(EM_SAVE); // Disable save mode mn.ToggleErrorMode(EM_EXCEPTION); // Enable exception mode try { mn.DNS("ERROR"); // Cause error } catch(mnError Error) { Console.WriteLine("An error occurred whilst " + Error.GetOperation()); } // MULTIPLE MODES // In this case: exception and message box // Note: exception mode is already on Console.WriteLine(); Console.WriteLine("Exception and message box mode (at the same time)"); mn.ToggleErrorMode(EM_MESSAGE_BOX); // Enable message box mode try { mn.DNS("ERROR"); // Cause error } catch(mnError Error) { Console.WriteLine("An error occurred whilst " + Error.GetOperation()); } Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); return; } } }