JsonParseError class: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (minor cleanup)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<!-- JsonParseError class -->
__NOTOC__
JsonParseError exceptions are typically thrown by the Json class [[Parse (Json function)|Parse function]] and the equivalent Unicode [[JsonParse (Unicode function)|JsonParse function]] class when there is an error parsing JSON data.
<var>JsonParseError</var> exceptions are typically thrown by the <var>[[Parse (Json function)|Parse]]</var> function in the <var>[[Json class|Json]]</var> class and by the equivalent <var>[[Unicode class|Unicode]]</var> class <var>[[JsonParse (Unicode function)|JsonParse]]</var> function when there is an error parsing JSON data.
   
   
To create a <var>JsonParseError</var> exception yourself, you typically use a SOUL <var>[[Exceptions#Using the Throw statement|Throw]]</var> statement with an <var>JsonParseError</var> <var>[[New_(JsonParseError_constructor)|New]]</var> 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 <var>JsonParseError</var> exception:
To create a <var>JsonParseError</var> exception yourself, you typically use a SOUL <var>[[Exceptions#Using the Throw statement|Throw]]</var> statement with a <var>JsonParseError</var> <var>[[New_(JsonParseError_constructor)|New]]</var> 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 <var>JsonParseError</var> exception:
<p class="code">throw %(JsonParseError):new(characterPosition=%pos)
<p class="code">throw %(JsonParseError):new(characterPosition=%pos)
</p>
</p>
   
   
Remember that you catch an exception with the <var>[[Exceptions#Try and Catch|Catch]]</var> statement; if an exception condition occurs outside a <var>Catch</var> for it, the request is canceled.
Remember that you catch an exception with the <var>[[Exceptions#Try and Catch|Catch]]</var> statement. If an exception condition occurs outside a <var>Catch</var> for it, the request is canceled.
   
   
The <var>JsonParseError</var> class, like the Json class is available as of <var class="product">Model 204</var> 7.6.
The <var>JsonParseError</var> class, like the <var>Json</var> class is available as of <var class="product">Model 204</var> 7.6.
   
   
==The JsonParseError methods==
==The JsonParseError methods==
Line 15: Line 15:
The methods in the class are described in the subsections that follow. In addition:
The methods in the class are described in the subsections that follow. In addition:
<ul>
<ul>
<li>[[Notation conventions for methods|"Notation conventions for methods"]] has information
<li>[[Notation conventions for methods]] has information
about the conventions followed.
about the conventions followed.</li>
<li>[[JsonParseError methods syntax|"JsonParseError methods syntax"]] is a single page that contains the syntax diagrams of all the methods in the class.
 
<li>[[JsonParseError methods syntax]] is a single page that contains the syntax diagrams of all the methods in the class.</li>
</ul>
</ul>
==CharacterPosition property==
==CharacterPosition property==
{{Template:JsonParseError:CharacterPosition subtitle}}
{{Template:JsonParseError:CharacterPosition subtitle}}
   
   
This <var>[[Classes and Objects#readWrite|ReadOnly]]</var> 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.  
This <var>[[Classes and Objects#readWrite|ReadOnly]]</var> 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===
===Syntax===
{{Template:JsonParseError:CharacterPosition syntax}}
{{Template:JsonParseError:CharacterPosition syntax}}


====Syntax terms====
====Syntax terms====
<table class="syntaxTable">
<table>
<tr><th>%number</th>
<tr><th>%number</th>
<td>The character position in the input unicode string where the parse error was detected.</td></tr>
<td>The character position in the input Unicode string where the parse error was detected.</td></tr>


<tr><th>jsonParseError</th>
<tr><th>jsonParseError</th>
<td>A reference to an instance of a <var>[[JsonParseError_class|JsonParseError]]</var> object.</td></tr>
<td>A reference to an instance of a <var>[[JsonParseError_class|JsonParseError]]</var> object.</td></tr>
</table>
==Description property==
{{Template:JsonParseError:Description subtitle}}
This <var>[[Classes and Objects#readWrite|ReadOnly]]</var> property returns a string that describes the error that was encountered while parsing the JSON data.
===Syntax===
{{Template:JsonParseError:Description syntax}}
====Syntax terms====
<table>
<tr><th>%string</th>
<td>Text the describes the error that was encountered while parsing JSON data.</td></tr>
<tr><th>jsonParseError</th>
<td>A reference to an instance of a <var>[[JsonParseError class|JsonParseError]]</var> object.</td></tr>
</table>
</table>


Line 38: Line 58:
{{Template:JsonParseError:New subtitle}}
{{Template:JsonParseError:New subtitle}}
   
   
This <var>Constructor</var> generates an instance of a <var>[[JsonParseError_class|JsonParseError]]</var> exception. The <var>New</var> method format follows:
This <var>Constructor</var> generates an instance of a <var>[[JsonParseError_class|JsonParseError]]</var> exception.
 
===Syntax===
===Syntax===
{{Template:JsonParseError:New syntax}}
{{Template:JsonParseError:New syntax}}
   
   
====Syntax terms====
====Syntax terms====
<table class="syntaxTable">
<table>
<tr><th>%jsonParseError</th><td>A reference to an instance of a <var>JsonParseError</var> object.</td></tr>
<tr><th>%jsonParseError</th><td>A reference to an instance of a <var>JsonParseError</var> object.</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><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>
<tr><th>string</th><td>Text that describes the error. It must be 127 characters long or less.</td></tr>
</table>
</table>


===Usage notes===
<ul>
<li>Since the JsonParseError exception does not provide
</ul>
[[Category:System exception classes]]
[[Category:System exception classes]]

Latest revision as of 16:13, 9 August 2016

JsonParseError exceptions are typically thrown by the Parse function in the Json class and by the equivalent Unicode class JsonParse function when there is an error parsing JSON data.

To create a JsonParseError exception yourself, you typically use a SOUL Throw statement with a 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.

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.