Exception handling
Armed Assault introduced exception handling through the try, catch and throw scripting commands, allowing scripts to create and react to exceptions.
Standard structure:
try // code block that can throw exception
{
if (_name == "") then { throw "no name"; }; // this exits the try block and enters the catch block below
if (_name == "") throw "no name"; // since Arma 3 v1.54
titleText [format ["Good morning, Captain %1.", _name], "PLAIN DOWN"];
}
catch // code block that processes an exception
{
if (_exception == "no name") then
{
hint "Name was not entered";
titleText ["Good morning, anonymous Captain.", "PLAIN DOWN"];
};
};