throw

The throw runtime statement permits you to generate your own runtime exceptions, ending the game and showing an error message, using the following syntax:

throw (<expression>);

The expression used can be a value or a string or any other data type, and this will then generate an exception error which is - by default - shown on the screen and on closing the error message the game will end. For example calling this:

throw ("Hello World!");

will cause the following unhandled exception error to be shown:

Unhandled runtime exception error message exampleYou can, however, take over this error message and use your own handler code by calling the function exception_unhandled_handler(). This runtime function permits you to supply a custom method to use that will be called whenever any unhandled exceptions occur in your game.