|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > JSON - Parser > Parser-Operations > !Utility and Conversion > PSJ. - JSON Operations |
SPR Script Language
PSJ.Errmsg
Retrieves the last JSON library error message.
Intention
The PSJ.Errmsg command in SPR retrieves the most recent error message generated by a JSON operation. Optionally, it stores this message in $$RET. It’s like asking your robot to explain in words what went wrong with your last JSON task.
For example, after a failed operation, it might return "Path not found" to describe the issue.
Illustration
📝 Get Error Message: PSJ.Errmsg retrieves the last error message.
📝 With Result: PSJ.Errmsg|$$MSG stores the last error message in $$MSG.
Syntax
PSJ.Errmsg[|$$RET]
Parameter Explanation
P1 - $$RET - (Variable, String, Optional)
The variable to store the error message (e.g., $$RET as "$$MSG"). Returns the last error message as a string or an empty string if no error has been recorded. If omitted, the message is returned but not stored.
Examples
'***********************************
' Sample 1: Get Last Error Message
PSJ.Errmsg
' Retrieves the last error message
MBX.Ready
'***********************************
' Sample 2: Store Error Message
PSJ.Errmsg|$$MSG
' Stores the last error message in $$MSG
IF $$MSG <> "" THEN PRT.Error: $$MSG ELSE PRT.No Error
MBX.Ready
Remarks
- $$RET returns an empty string if no error has occurred; otherwise, it returns a descriptive message about the last error.
- The error message persists until the next JSON operation updates it.
- Use with PSJ.Errcode for a numeric error code corresponding to this message.
Limitations
- Only reflects the most recent error message; earlier messages are overwritten.
See also: