AIU. - Artificial Intelligence Utility

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > AI - Artificial Intelligence Commands > AIU. - OpenAI API > !Error Handling >

AIU. - Artificial Intelligence Utility

AIU.GetLastErrorMsg

Previous Top Next


MiniRobotLanguage (MRL)

 

AIU.GetLastErrorMsg
Retrieves the last AIU-specific formatted error message.

 

Intention

 

The AIU.GetLastErrorMsg command (aliased as AIU.glerr) is an essential tool for debugging and error handling. After an AIU command fails, this command retrieves a detailed, human-readable error message that includes a timestamp, the function where the error occurred, the error code, and a description of the problem. This provides critical context for understanding why an operation did not succeed.

 

It’s your robot’s diagnostic report—AIU.GetLastErrorMsg tells you exactly what went wrong and where.

 

Illustration

 

┌──────────────────────────────────────────────────────────────────┐

│ AIU.Ask (Fails)                                                  │

├──────────────────────────────────────────────────────────────────┤

│ ❌ Error Occurs                                                  │

├──────────────────┬───────────────────────────────────────────────┤

│ Next Cmd         │ Result                                        │

├──────────────────┼───────────────────────────────────────────────┤

│ GetLastErrorMsg  │ "[timestamp] Error(101): API key not set."    │

└──────────────────┴───────────────────────────────────────────────┘

Retrieving a detailed error message after a command fails.

 

Syntax

 

AIU.GetLastErrorMsg|$$RET[|$$COD]

 

Parameter Explanation

 

P1 - $$RET - (Variable, String, Required)

The variable where the formatted error message string will be stored.

 

P2 - $$COD - (Variable, Numeric, Optional)

An optional variable where the corresponding numeric error code will also be stored.

 

Examples

 

'***********************************

' AIU.GetLastErrorMsg - Sample 1: Handling a failed API call

'***********************************

AIU.SetKey| ' Intentionally set an empty key to cause an error

AIU.Ask|Hello|$$RES

 

' Check the error code first

AIU.GetLastError|$$ERR

JIV.$$ERR=0|No_Error

 

' If an error occurred, get the detailed message

AIU.GetLastErrorMsg|$$MSG

MBX.Error Details:|$$MSG

END.

 

:No_Error

MBX.Success:|API call was successful.

END.

 

 

Remarks

 

- The alias AIU.glerr can be used for convenience.

- The error message is specific to the last AIU command that was executed in the current thread. It is not cleared until the next AIU command is run or AIU.ClearError is called.

- This command complements AIU.GetLastError, which retrieves only the numeric error code.

 

See also:

 

AIU.GetLastError

AIU.GetErrorHistory

AIU.ClearError