WriteError class: Difference between revisions
m (add clarifying phrase) |
No edit summary |
||
Line 4: | Line 4: | ||
Before the existence of the <var>WriteError</var> exception class, these <var>Dataset</var> methods would cancel the request in this situation. With the exception, the full condition is brought to your attention with an opportunity to take some mitigating action. | Before the existence of the <var>WriteError</var> exception class, these <var>Dataset</var> methods would cancel the request in this situation. With the exception, the full condition is brought to your attention with an opportunity to take some mitigating action. | ||
To create a <var>WriteError</var> exception yourself, you typically use a SOUL <var>[[Exceptions#Using the Throw statement|Throw]]</var> statement with | To create a <var>WriteError</var> exception yourself, you typically use a SOUL <var>[[Exceptions#Using the Throw statement|Throw]]</var> statement with a <var>WriteError</var> <var>[[New_(WriteError_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>WriteError</var> exception: | ||
<p class="code">throw %(WriteError):new(returnCode=%rc) | <p class="code">throw %(WriteError):new(returnCode=%rc) | ||
</p> | </p> | ||
Line 52: | Line 52: | ||
</table> | </table> | ||
==New constructor== | ==New constructor== | ||
{{Template:WriteError:New subtitle}} | {{Template:WriteError:New subtitle}} |
Latest revision as of 20:41, 17 August 2016
WriteError exceptions are thrown by the Close, WriteBlock, WriteRecord, and WriteRecords methods in the Dataset class if they encounter a full output Dataset object.
Before the existence of the WriteError exception class, these Dataset methods would cancel the request in this situation. With the exception, the full condition is brought to your attention with an opportunity to take some mitigating action.
To create a WriteError exception yourself, you typically use a SOUL Throw statement with a WriteError 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 WriteError exception:
throw %(WriteError):new(returnCode=%rc)
Remember that you catch an exception with the Catch statement. If an exception condition occurs outside a Catch for it, the request is canceled. Here is a sample testing loop with a Dataset object:
for %i from 1 to 10000 try %ds:writeRecord("This is a test " %i) catch writeError to %writeError printText {~=%writeError:returnCode} loop end end try end for
The WriteError class is available as of Model 204 7.7.
The WriteError methods
The following are the available WriteError class methods.
Method | Description |
---|---|
New | Create a new WriteError object |
ReturnCode | Return code from failed write |
The methods in the class are described in the subsections that follow. In addition:
- Notation conventions for methods has information about the conventions followed.
- WriteError methods syntax is a single page that contains the syntax diagrams of all the methods in the class.
ReturnCode property
Return code from failed write (WriteError class)
This ReadOnly property returns a number that indicates the type of error encountered.
Syntax
%number = writeError:ReturnCode
Syntax terms
%number | An I/O error return code. The most likely codes are:
4 Permanent I/O error 10 Offload process failed 12 File full condition |
---|---|
writeError | A reference to an instance of a WriteError object. |
New constructor
Create a new WriteError object (WriteError class)
This Constructor generates an instance of a WriteError exception.
Syntax
%writeError = [%(WriteError):]New( ReturnCode= number)
Syntax terms
%writeError | A reference to an instance of a WriteError object. |
---|---|
[%(WriteError):] | The class name in parentheses denotes a Constructor. |
number | A ReturnCode property value that indicates the type of error encountered. |