JsonParseError class: Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Created page with "<!-- JsonParseError class --> JsonParseError exceptions are typically thrown by the Json class Parse function and the equivalent Unicode JsonParse...")
 
Line 47: Line 47:
<tr><th><var>[%(JsonParseError):]</var></th><td>The class name in parentheses denotes a <var>[[Notation conventions for methods#Constructors|Constructor]]</var>.</td></tr>
<tr><th><var>[%(JsonParseError):]</var></th><td>The class name in parentheses denotes a <var>[[Notation conventions for methods#Constructors|Constructor]]</var>.</td></tr>
<tr><th>number</th><td>The character position in the input unicode string where the parse error was detected.</td></tr>
<tr><th>number</th><td>The character position in the input unicode string where the parse error was detected.</td></tr>
<tr><th>string</th><td>Text that describes the error. It must be 127 characters long or less.</td></tr>
</table>
</table>



Revision as of 21:30, 18 February 2015

JsonParseError exceptions are typically thrown by the Json class Parse function 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.

MethodDescription
CharacterPositionPosition of character at which error was detected
DescriptionDescription of the error
NewCreate a new JsonParseError object

The methods in the class are described in the subsections that follow. In addition:

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.

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

%jsonParseErrorA reference to an instance of a JsonParseError object.
[%(JsonParseError):]The class name in parentheses denotes a Constructor.
numberThe character position in the input unicode string where the parse error was detected.
stringText that describes the error. It must be 127 characters long or less.

Usage notes

  • Since the JsonParseError exception does not provide