|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > AIU. - OpenAI API > !Error Handling > AIU. - Artificial Intelligence Utility |
MiniRobotLanguage (MRL)
AIU.GetErrorHistory
Retrieves the cumulative error log for the current session.
Intention
The AIU.GetErrorHistory command (aliased as AIU.gerrh) provides a complete, chronological log of all errors that have occurred within the AIU library during the current script session. Each time an AIU command fails, a detailed, timestamped entry is added to this history. This command is an essential tool for debugging complex scripts, as it allows you to see the sequence of errors that led to a failure, rather than just the single most recent one.
It’s your robot’s black box recorder—AIU.GetErrorHistory gives you the full story of what went wrong.
Illustration
┌───────────────────────────────────────┐
│ Script Execution │
├───────────────────────────────────────┤
│ 1. AIU.SetKey| (empty) -> Error 101 │
│ 2. AIU.Ask|Hello -> Error 104 │
├───────────────────────────────────────┤
│ AIU.GetErrorHistory|$$LOG │
├───────────────────────────────────────┤
│ $$LOG = "...Error 101... │
│ ...Error 104..." │
└───────────────────────────────────────┘
Retrieving the log of all accumulated errors.
Syntax
AIU.GetErrorHistory|$$RET[|$$COD]
Parameter Explanation
P1 - $$RET - (Variable, String, Required)
The variable where the multi-line error history log will be stored.
P2 - $$COD - (Variable, Numeric, Optional)
An optional variable to store the most recent error code, identical to calling AIU.GetLastError.
Examples
'***********************************
' AIU.GetErrorHistory - Sample 1: Retrieving the error log
'***********************************
' Intentionally cause a couple of errors
AIU.SetKey|' This will cause an API key missing error
AIU.Ask|Hello
AIU.GenerateImageURL|A blue car' This will also fail
' Now, get the history of what happened
AIU.GetErrorHistory|$$LOG|$$COD
MBX.Last Error Code: $$COD|Log
MBX.Full Error History:|$$LOG
END.
Remarks
- The alias AIU.gerrh can be used for convenience.
- The history is a multi-line string, with each error on a new line, delimited by $crlf$.
- The history log is automatically trimmed to prevent it from growing indefinitely (typically the last 50 errors are kept).
- Use AIU.ClearError|1 to clear the history log.
See also: