try: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
Line 40: Line 40:
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on June 9, 2015 - 20:52 (UTC)</dd>
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dd class="note">
Do not expect this behave like Javascript try catch and ignore all errors. But it does have one useful behaviour. Normally when runtime error occurs in SQF (unlike when there is compile error) it continues to execute till the end. But if the script is placed in [[try]] {} scope and [[throw]] is used upon error, the script immediately terminates, exits the [[try]] {} scope and enters [[catch]] {} scope. This way it is possible to process possible exceptions in civilised manner.
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Revision as of 21:52, 9 June 2015

-wrong parameter ("Arma") defined!-1.00
Hover & click on the images for description

Description

Description:
Defines a try-catch structure. This sets up an exception handling block. Any thrown exception in a try block is caught in a catch block. The structured exception block has following form: try //begin of try-catch block { //block, that can throw exception } catch { //block, that process an exception. Exception is described in _exception variable };
Groups:
Uncategorised

Syntax

Syntax:
try code
Parameters:
code: Code
Return Value:
Exception Type

Examples

Examples:
Example needed

Additional Information

See also:
Exception handling

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note

Notes

Bottom Section

Posted on June 9, 2015 - 20:52 (UTC)
Killzone Kid
Do not expect this behave like Javascript try catch and ignore all errors. But it does have one useful behaviour. Normally when runtime error occurs in SQF (unlike when there is compile error) it continues to execute till the end. But if the script is placed in try {} scope and throw is used upon error, the script immediately terminates, exits the try {} scope and enters catch {} scope. This way it is possible to process possible exceptions in civilised manner.