RuntimeError message$
Parameters
| message$ - error text to display (anything past 255 characters is trimmed) |
Description
|
Ends the program with a runtime error box showing your own message. Use this for your own fatal error checks - a missing data file, a corrupt save, a level that failed to load. The message appears in the standard runtime error box, exactly like the errors the engine itself raises, and the program then ends. When running from the IDE in debug mode, the editor highlights the line that raised the error, which makes RuntimeError a useful tripwire while developing. There is no way to continue past it, so reserve RuntimeError for situations the game genuinely cannot recover from - for anything you can handle, just deal with it in code (or log it with DebugLog instead). See also: DebugLog, Stop, End. |
Example
; RuntimeError Example ; -------------------- ; RuntimeError halts the program with a fatal error box showing your ; own message - useful for your own error trapping. Print "This example can raise a deliberate runtime error." Print "" Print "Press and hold Y to raise the error, or any other key to skip" WaitKey ; WaitKey returns as the key goes down, so the chosen key is still held If KeyDown(21) Then ; The error box appears, then the program ends immediately RuntimeError "Installation corrupted. Please reinstall." EndIf Print "No error raised - carrying on normally." Print "" Print "Press any key to close the example" WaitKey End
Index