Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

Difference between revisions of "error"

From Quake Wiki

(Created page with "====Syntax:==== <code>void error(string message)</code> Halts execution and displays and error message. ====Parameters:==== :<code>message</code> - The error message to displ...")
 
 
Line 1: Line 1:
====Syntax:====
+
''void'' '''error'''(''string'' message)
<code>void error(string message)</code>
 
  
Halts execution and displays and error message.
+
== Usage ==
====Parameters:====
+
Throws an abort exception in the VM and halts all execution of the game. This should be used for any game-breaking errors that cannot be recovered from.
:<code>message</code> - The error message to display
 
====Returns:====
 
:void
 
  
 +
=== Parameters ===
 +
*''message''
 +
:The message to display in the console.
 +
 +
== Example ==
 +
// This advanced server system uses a global to determine if the game state is valid
 +
// If the state is invalid, it forcefully exits the game
 +
void UpdateGameState()
 +
{
 +
    if (gameState == GS_INVALID)
 +
        error("Game state encountered a fatal error\n");
 +
 +
    // ...
 +
}
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Latest revision as of 12:06, 31 July 2023

void error(string message)

Usage[edit]

Throws an abort exception in the VM and halts all execution of the game. This should be used for any game-breaking errors that cannot be recovered from.

Parameters[edit]

  • message
The message to display in the console.

Example[edit]

// This advanced server system uses a global to determine if the game state is valid
// If the state is invalid, it forcefully exits the game
void UpdateGameState()
{
    if (gameState == GS_INVALID)
        error("Game state encountered a fatal error\n");

    // ...
}