PSJ. - JSON Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > JSON - Parser >

PSJ. - JSON Operations

PSJ. - JSON Error Codes

Top


SPR Script Language

 

PSJ. - JSON Error Codes

Reference list of error codes returned by PSJ. commands.

 

Intention

 

This page provides a comprehensive list of the numeric error codes that can be returned by various PSJ. commands, typically in the optional $$RET parameter or via the PSJ.ErrCode command. Understanding these codes helps in diagnosing issues and implementing robust error handling in your scripts. A return code of 0 (%JSON_ERR_NONE) always indicates success.

 

Error Code List

 

Error Code

Internal Constant

Description

0

%JSON_ERR_NONE

Operation completed successfully. No error occurred.

1

%JSON_ERR_INVALID

An invalid parameter, document handle, or state was encountered (e.g., empty path, inactive handle).

2

%JSON_ERR_NOTFOUND

The specified node or key could not be found at the given path.

3

%JSON_ERR_SYNTAX

A general JSON syntax error occurred during parsing (e.g., missing comma, colon, quote, bracket).

4

%JSON_ERR_RANGE

An array index or numeric value was outside its expected or valid range.

5

%JSON_ERR_TYPE

Operation is not valid for the node's type (e.g., trying to get a key from an array, appending to a string).

6

%JSON_ERR_MEMORY

Memory allocation failed during the operation (e.g., creating node, resizing internal array).

7

%JSON_ERR_RUNTIME

An unexpected internal error or invalid state occurred during execution.

8

%JSON_ERR_PARSE

A general error occurred during the parsing phase (may encompass syntax errors or other issues like invalid start/end).

9

%JSON_ERR_DUPLICATE

A duplicate key was detected during an operation. (Note: Less likely for objects using WsLnTre, which handles duplicates during Set/Add).

10

%JSON_ERR_UNEXPECTED

An unexpected character or token was found during parsing where something else was expected.

11

%JSON_ERR_LIMIT

An internal resource limit was exceeded (e.g., maximum number of nodes or document handles).

12

%JSON_ERR_ADD_CHILD

An error occurred specifically during the process of linking a child node to a parent.

13

%JSON_ERR_DUPLICATE_SUBTREE

An error occurred during the deep copy (duplication) of a node subtree.

14

%JSON_ERR_INVALID_NODE

The provided Node ID is invalid (e.g., out of bounds, zero, or refers to a previously freed node).

16

%JSON_ERR_INVALID_PATH

The provided path string has invalid syntax or is empty when not permitted.

17

%JSON_ERR_TREE_ERROR

An error originated from the underlying WsLnTre library during an object operation (add, remove, find, create, etc.). Check the error message for more details.

 

Remarks

 

§ Commands that return a status code typically use 0 (%JSON_ERR_NONE) for success and one of the non-zero codes above for different errors.

§ Always check the return code (e.g., in $$RET) after calling a PSJ command that provides one.

§ If an error occurs (non-zero code), use PSJ.ErrCode to retrieve the last error code set by the library and PSJ.ErrMsg to get the corresponding descriptive error message for debugging.

§ Note that `%JSON_ERR_CREATE_PAYLOAD` (15) is typically reserved for specific external use cases and might not be directly generated by standard PSJ commands.

 

See also:

 

PSJ. - JSON Operations Overview (WsLnTre)

PSJ.ErrCode

PSJ.ErrMsg