idTech4.idSystem.Error C# (CSharp) Method

Error() private method

private Error ( string format ) : void
format string
return void
		internal void Error(string format, params object[] args)
		{
			ErrorType code = ErrorType.Drop;

			// always turn this off after an error
			_refreshOnPrint = false;

			// when we are running automated scripts, make sure we
			// know if anything failed
			if(idE.CvarSystem.GetInteger("fs_copyfiles") > 0)
			{
				code = ErrorType.Fatal;
			}

			// if we don't have GL running, make it a fatal error
			if(idE.RenderSystem.IsRunning == false)
			{
				code = ErrorType.Fatal;
			}

			// if we got a recursive error, make it fatal
			if(_errorEntered > 0)
			{
				// if we are recursively erroring while exiting
				// from a fatal error, just kill the entire
				// process immediately, which will prevent a
				// full screen rendering window covering the
				// error dialog
				if(_errorEntered == ErrorType.Fatal)
				{
					this.Exit();
				}

				code = ErrorType.Fatal;
			}

			// if we are getting a solid stream of ERP_DROP, do an ERP_FATAL
			int currentTime = this.Milliseconds;

			if((currentTime - _lastErrorTime) < 100)
			{
				if(++_errorCount > 3)
				{
					code = ErrorType.Fatal;
				}
			}
			else
			{
				_errorCount = 0;
			}

			_lastErrorTime = currentTime;
			_errorEntered = code;

			string errorMessage = string.Format(format, args);

			// copy the error message to the clip board
			// TODO: SetClipboardData(errorMessage);

			// add the message to the error list
			if(_errorList.Contains(errorMessage) == false)
			{
				_errorList.Add(errorMessage);
			}

			if(code == ErrorType.Disconnect)
			{
				_errorEntered = ErrorType.None;

				throw new Exception(errorMessage);
			}
			else if(code == ErrorType.Drop)
			{
				idConsole.WriteLine("********************");
				idConsole.WriteLine("ERROR: {0}", errorMessage);
				idConsole.WriteLine("********************");

				_errorEntered = ErrorType.None;

				// TODO throw new Exception(errorMessage);
			}
			else
			{
				idConsole.WriteLine("********************");
				idConsole.WriteLine("ERROR: {0}", errorMessage);
				idConsole.WriteLine("********************");
			}

			if(idE.CvarSystem.GetBool("r_fullscreen") == true)
			{
				idE.CmdSystem.BufferCommandText(Execute.Now, "vid_restart partial windowed\n");
			}
			
			Shutdown();
			Sys_Error(errorMessage);
		}