{"name":"BIS_fnc_error","operator":null,"title":"BIS fnc error","type":"function","url":"https://community.bistudio.com/wiki/BIS_fnc_error","revid":352467,"updated":"2024-02-11T23:23:56Z","groups":["Diagnostic"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma3","name":"Arma 3","version":"0.50"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Logs an error message and shows an ingame error message. The message is shown when either of the following is true:\n\n- In 2D Editor\n- In Eden Editor via BIS_fnc_3DENNotification\n- Display `313` (Eden Editor display) is available\n- `profileNamespace getVariable [\"BIS_fnc_init_displayErrors\", false]` is set to `true`.\n\n**Output format:**\n\n- In multiplayer (isMultiplayer) the function will add the profileName in front of the message\n- If `_fnc_error_exit` is set to `true` before the function call, the log message will display `HALT:` instead of `ERROR:`\n- 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\n\n> [!NOTE]\n> `allowFunctionsLog` has to be set to **1** in Description.ext for this function to have any effect.","syntaxes":[{"syntax":"[message, param1, ..., paramN] call BIS_fnc_error","since":null,"effect":null,"exec":null,"params":[{"name":"message","type":"String","optional":false,"default":null,"description":"(formatted) logged message","types":["String"],"since":null,"text":"message: String - (formatted) logged message"},{"name":"param1..paramN","type":"Anything","optional":true,"default":null,"description":"format arguments, if any","types":["Anything"],"since":null,"text":"param1..paramN: Anything - (Optional) format arguments, if any"}],"returns":{"type":"Array in format: [message, param1..paramN]","types":["Array"],"description":null,"text":"Array in format: [message, param1..paramN]"}}],"examples":[{"text":"```sqf\n[\"Player is too far away (%1 metres)\", round (player distance [0, 0, 0])] call BIS_fnc_error;\n```","code":["[\"Player is too far away (%1 metres)\", round (player distance [0, 0, 0])] call BIS_fnc_error;"]},{"text":"```sqf\n// some useful function cases\nif (!isServer) exitWith { [\"This function must run on the server\"] call BIS_fnc_error };\nif (!hasInterface) exitWith { [\"This function must not run on a headless machine\"] call BIS_fnc_error };\nif (!local _vehicle) exitWith { [\"This function must run on the vehicle owner's machine\"] call BIS_fnc_error };\n```","code":["// some useful function cases\nif (!isServer) exitWith { [\"This function must run on the server\"] call BIS_fnc_error };\nif (!hasInterface) exitWith { [\"This function must not run on a headless machine\"] call BIS_fnc_error };\nif (!local _vehicle) exitWith { [\"This function must run on the vehicle owner's machine\"] call BIS_fnc_error };"]},{"text":"```sqf\n// Change rpt log to \"HALT\" indicating that function exited\nprivate _fnc_error_exit = true;\nif (exitHere) exitWith\n{\n    \"Some error message!\" call BIS_fnc_error; // Output in rpt: \"log: HALT: [BIS_fnc_debugConsoleExec] Some error message!\"\n};\n```","code":["// Change rpt log to \"HALT\" indicating that function exited\nprivate _fnc_error_exit = true;\nif (exitHere) exitWith\n{\n\t\"Some error message!\" call BIS_fnc_error; // Output in rpt: \"log: HALT: [BIS_fnc_debugConsoleExec] Some error message!\"\n};"]},{"text":"```sqf\nprivate _fnc_scriptName = \"My_Awesome_Custom_Function\";\n\"Some error message!\" call BIS_fnc_error; // Output in rpt: \"log: ERROR: [My_Awesome_Custom_Function] Some error message!\"\n```","code":["private _fnc_scriptName = \"My_Awesome_Custom_Function\";\n\"Some error message!\" call BIS_fnc_error; // Output in rpt: \"log: ERROR: [My_Awesome_Custom_Function] Some error message!\""]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["BIS_fnc_errorMsg","BIS_fnc_log","BIS_fnc_logFormat","BIS_fnc_logFormatServer"],"notes":[],"categories":["Arma 3: Functions","Arma 3: New Functions","Function Group: Diagnostic","Functions","Introduced with Arma 3 version 0.50"],"docblock":null,"filled_from_docblock":[]}