JsonParseError class: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
<!-- JsonParseError class --> | <!-- JsonParseError class --> | ||
__NOTOC__ | |||
JsonParseError exceptions are typically thrown by the [[Parse (Json function)|Parse function]] in the [[Json class]] and the equivalent Unicode [[JsonParse (Unicode function)|JsonParse function]] class when there is an error parsing JSON data. | JsonParseError exceptions are typically thrown by the [[Parse (Json function)|Parse function]] in the [[Json class]] and the equivalent Unicode [[JsonParse (Unicode function)|JsonParse function]] class when there is an error parsing JSON data. | ||
Revision as of 18:43, 4 May 2015
JsonParseError exceptions are typically thrown by the Parse function in the Json class and the equivalent Unicode JsonParse function class when there is an error parsing JSON data.
To create a JsonParseError exception yourself, you typically use a SOUL Throw statement with an JsonParseError New constructor. This statement must be issued from within a method, and it can only be caught by the code that calls the method. For example, the following statement throws a JsonParseError exception:
throw %(JsonParseError):new(characterPosition=%pos)
Remember that you catch an exception with the Catch statement; if an exception condition occurs outside a Catch for it, the request is canceled.
The JsonParseError class, like the Json class is available as of Model 204 7.6.
The JsonParseError methods
The following are the available JsonParseError class methods.
Method | Description |
---|---|
CharacterPosition | Position of character at which error was detected |
Description | Description of the error |
New | Create a new JsonParseError object |
The methods in the class are described in the subsections that follow. In addition:
- "Notation conventions for methods" has information about the conventions followed.
- "JsonParseError methods syntax" is a single page that contains the syntax diagrams of all the methods in the class.
CharacterPosition property
Position of character at which error was detected (JsonParseError class)
This ReadOnly property returns a number that indicates the character position (unicode characters are each two bytes long) in the unicode string being parsed where the error was detected.
Syntax
%number = jsonParseError:CharacterPosition
Syntax terms
%number | The character position in the input unicode string where the parse error was detected. |
---|---|
jsonParseError | A reference to an instance of a JsonParseError object. |
Description property
Description of the error (JsonParseError class)
This ReadOnly property returns a string that describes the error that was encountered while parsing the JSON data.
Syntax
%string = jsonParseError:Description
Syntax terms
%string | Text the describes the error that was encountered while parsing JSON data. |
---|---|
jsonParseError | A reference to an instance of a JsonParseError object. |
New constructor
Create a new JsonParseError object (JsonParseError class)
This Constructor generates an instance of a JsonParseError exception. The New method format follows:
Syntax
%jsonParseError = [%(JsonParseError):]New( CharacterPosition= number, - Description= string)
Syntax terms
%jsonParseError | A reference to an instance of a JsonParseError object. |
---|---|
[%(JsonParseError):] | The class name in parentheses denotes a Constructor. |
number | The character position in the input unicode string where the parse error was detected. |
string | Text that describes the error. It must be 127 characters long or less. |
Usage notes
- Since the JsonParseError exception does not provide