WriteError class

From m204wiki
Revision as of 16:47, 9 August 2016 by JAL (talk | contribs) (provide content)
Jump to navigation Jump to search

WriteError exceptions are thrown by the Close, WriteBlock, WriteRecord, and WriteRecords methods in the Dataset class if they encounter a full dataset. The problem with this approach is if the dataset fills on your last write or maybe on the Close (since Close flushes buffers and checks pending writes) you might never notice that your dataset filled up. Silently, allowing a dataset to be truncated doesn’t seem like a good idea.

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

The WriteError class is available as of Model 204 7.7.

The WriteError methods

The following are the available WriteError class methods.

MethodDescription
NewCreate a new WriteError object
ReturnCodeReturn code from failed write

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

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.