BIS fnc error: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(More info about condition to show error msg)
(Added information on how to manipulate rpt message)
Line 14: Line 14:
* <sqf inline>profilenamespace getvariable ["BIS_fnc_init_displayErrors",false]</sqf> is set to <sqf inline>true</sqf>.
* <sqf inline>profilenamespace getvariable ["BIS_fnc_init_displayErrors",false]</sqf> is set to <sqf inline>true</sqf>.


If it is called from a function, it will include that function's name before the provided message.
'''Output format:'''


Output is: {{hl|[[profileName]]/log: ERROR: <message>}}
* In multiplayer ([[isMultiplayer]]) the function will add the [[profileName]] in front of the message
* If <sqf inline>_fnc_error_exit</sqf> is set to <sqf inline>true</sqf> before the function call, the log message will display {{hl|HALT:}} instead of {{hl|ERROR:}}
* If function is called from within another function, the name of the parent function will be displayed. This can be overwritten by setting <sqf inline>_fnc_scriptName</sqf> to a custom value


{{Feature|informative|{{hl|[[Description.ext#allowFunctionsLog|allowFunctionsLog]]}} has to be set to '''1''' in [[Description.ext]] for this function to have any effect.}}
{{Feature|informative|{{hl|[[Description.ext#allowFunctionsLog|allowFunctionsLog]]}} has to be set to '''1''' in [[Description.ext]] for this function to have any effect.}}
Line 36: Line 38:
if (!local _vehicle) exitWith { ["This function must run on the vehicle owner's machine"] call BIS_fnc_error };
if (!local _vehicle) exitWith { ["This function must run on the vehicle owner's machine"] call BIS_fnc_error };
</sqf>
</sqf>
|x3= <sqf>
// Change rpt log to "HALT" indicating that function exited
_fnc_error_exit = true;
if (exitHere) exitWith
{
  "Some error message!" call BIS_fnc_error; // Output in rpt: "log: HALT: [BIS_fnc_debugConsoleExec] Some error message!"
};</sqf>
|x4= <sqf>
_fnc_scriptName = "My_Awesome_Custom_Function";
"Some error message!" call BIS_fnc_error; // Output in rpt: "log: ERROR: [My_Awesome_Custom_Function] Some error message!"</sqf>


|seealso= [[BIS_fnc_errorMsg]] [[BIS_fnc_log]] [[BIS_fnc_logFormat]] [[BIS_fnc_logFormatServer]]
|seealso= [[BIS_fnc_errorMsg]] [[BIS_fnc_log]] [[BIS_fnc_logFormat]] [[BIS_fnc_logFormatServer]]
}}
}}

Revision as of 11:19, 13 January 2024

Hover & click on the images for description

Description

Description:
BIS fnc error.png

Logs an error message and shows an ingame error message. The message is shown when either of the following is true:

Output format:

  • In multiplayer (isMultiplayer) the function will add the profileName in front of the message
  • If _fnc_error_exit is set to true before the function call, the log message will display HALT: instead of ERROR:
  • If function is called from within another function, the name of the parent function will be displayed. This can be overwritten by setting _fnc_scriptName to a custom value
allowFunctionsLog has to be set to 1 in Description.ext for this function to have any effect.
Execution:
call
Groups:
Diagnostic

Syntax

Syntax:
[message, param1, ..., paramN] call BIS_fnc_error
Parameters:
message: String - (formatted) logged message
param1..paramN: Anything - (Optional) format arguments, if any
Return Value:
Array in format: [message, param1..paramN]

Examples

Example 1:
["Player is too far away (%1 metres)", round (player distance [0, 0, 0])] call BIS_fnc_error;
Example 2:
// some useful function cases if (!isServer) exitWith { ["This function must run on the server"] call BIS_fnc_error }; if (!hasInterface) exitWith { ["This function must not run on a headless machine"] call BIS_fnc_error }; if (!local _vehicle) exitWith { ["This function must run on the vehicle owner's machine"] call BIS_fnc_error };
Example 3:
// Change rpt log to "HALT" indicating that function exited _fnc_error_exit = true; if (exitHere) exitWith { "Some error message!" call BIS_fnc_error; // Output in rpt: "log: HALT: [BIS_fnc_debugConsoleExec] Some error message!" };
Example 4:
_fnc_scriptName = "My_Awesome_Custom_Function"; "Some error message!" call BIS_fnc_error; // Output in rpt: "log: ERROR: [My_Awesome_Custom_Function] Some error message!"

Additional Information

See also:
BIS_fnc_errorMsg BIS_fnc_log BIS_fnc_logFormat BIS_fnc_logFormatServer

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