JsonParseError class: Difference between revisions

From m204wiki
Jump to navigation Jump to search
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.

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.

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

%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