Category: Developer
Since engine version: 1.0 OC


Prints out the specified error message and the call stack, then cancels the execution of the function it was called in. This function can e.g. be used to effectively debug scripts or to throw an error if required parameters of a function are not given by the user of the function.


bool FatalError(string message,  ...);


[opt] Error message to be displayed
[opt] Additional parameters for text formatting.


global func Explode(int level)
	if(!this) FatalError("Function Explode must be called from object context");
A snippet from the actual implementation of the Explode function. If Explode is called without object context, the error message and call stack are printed into the log file and the execution of the function is canceled.
This is better than the following behaviour of Explode...
global func Explode(int level)
	if(!this) return;
...because it just silently stops the execution of Explode without notifying the developer about this error. This would make it harder for the developer to trace down the actual bug that led to the illegal call.
Let's say we want to trace down a bug where clonks are unexplicably removed from the landscape seemingly at random and we have no clues which object, effect or scenario script could be responsible for it. We can trace down this bug easily by temporarily overloading RemoveObject and triggering a fatal error each time a clonk is removed. As soon as a Clonk is about to be deleted, the execution of RemoveObject is stopped and the call stack is printed out. (Don't forget to remove that function again when you are done.)
global func RemoveObject()
	if(this->GetID() == Clonk) FatalError("See call stack for who is responsible for the removal of Clonks");
	return inherited(...);
See also: LogCallStack
Marky, 2018-04
Newton, 2011-09