|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > AIG. - Google AI > AIG. - AI Google Gemini Integration |
MiniRobotLanguage (MRL)
10. Error Handling
Debugging and Reliability Tools
Overview
AI integrations involve complex interactions between your script, the network, and Google's servers. Things can go wrong: the internet might drop, the API key might expire, or the model might refuse a prompt due to safety settings.
The AIG library is designed not to crash your robot on failure. Instead, it sets an internal error state that you can check programmatically.
The "Silent Failure" Philosophy
•If a command fails (e.g., AIG.Ask), it usually returns an empty string.
•It does not pop up an error box automatically.
•It records the details internally.
•You must use the commands below to inspect what happened.
Available Commands
•AIG.GetError - Retrieves the last error message and code. Use this immediately after a command returns an empty result to find out why.
•AIG.GetErrorHistory - Retrieves a full, multi-line log of all errors that occurred since the script started (or was last cleared). Useful for forensic debugging.
•AIG.ClearError - Resets the error state to "OK". Use this inside retry loops to ensure a clean state before a new attempt.
Debugging Workflow
1.Run an Action (e.g., AIG.Ask).
2.Check if the output variable is empty.
3.If empty, call AIG.GetError into a variable.
4.Decide based on the error code:204 (Network): Wait and Retry.
5.201 (Auth): Stop and ask user for Key.
6.208 (API Error): Check prompt or model availability.
See also: