Go to the first, previous, next, last section, table of contents.
-
The package IO_Exceptions defines the exceptions needed by the
predefined input-output packages.
Static Semantics
-
The library package IO_Exceptions has the following declaration:
-
package Ada.IO_Exceptions is
pragma Pure(IO_Exceptions);
-
Status_Error : exception;
Mode_Error : exception;
Name_Error : exception;
Use_Error : exception;
Device_Error : exception;
End_Error : exception;
Data_Error : exception;
Layout_Error : exception;
-
end Ada.IO_Exceptions;
-
If more than one error condition exists, the corresponding exception
that appears earliest in the following list is the one that is
propagated.
-
The exception Status_Error is propagated by an attempt to operate upon a
file that is not open, and by an attempt to open a file that is already
open.
-
The exception Mode_Error is propagated by an attempt to read from, or
test for the end of, a file whose current mode is Out_File or
Append_File, and also by an attempt to write to a file whose current
mode is In_File. In the case of Text_IO, the exception Mode_Error is
also propagated by specifying a file whose current mode is Out_File or
Append_File in a call of Set_Input, Skip_Line, End_Of_Line, Skip_Page,
or End_Of_Page; and by specifying a file whose current mode is In_File
in a call of Set_Output, Set_Line_Length, Set_Page_Length, Line_Length,
Page_Length, New_Line, or New_Page.
-
The exception Name_Error is propagated by a call of Create or Open if
the string given for the parameter Name does not allow the
identification of an external file. For example, this exception is
propagated if the string is improper, or, alternatively, if either none
or more than one external file corresponds to the string.
-
The exception Use_Error is propagated if an operation is attempted that
is not possible for reasons that depend on characteristics of the
external file. For example, this exception is propagated by the
procedure Create, among other circumstances, if the given mode is
Out_File but the form specifies an input only device, if the parameter
Form specifies invalid access rights, or if an external file with the
given name already exists and overwriting is not allowed.
-
The exception Device_Error is propagated if an input-output operation
cannot be completed because of a malfunction of the underlying system.
-
The exception End_Error is propagated by an attempt to skip (read past)
the end of a file.
-
The exception Data_Error can be propagated by the procedure Read (or by
the Read attribute) if the element read cannot be interpreted as a value
of the required subtype. This exception is also propagated by a
procedure Get (defined in the package Text_IO) if the input character
sequence fails to satisfy the required syntax, or if the value input
does not belong to the range of the required subtype.
-
The exception Layout_Error is propagated (in text input-output) by Col,
Line, or Page if the value returned exceeds Count'Last. The exception
Layout_Error is also propagated on output by an attempt to set column or
line numbers in excess of specified maximum line or page lengths,
respectively (excluding the unbounded cases). It is also propagated by
an attempt to Put too many characters to a string.
Documentation Requirements
-
The implementation shall document the conditions under which Name_Error,
Use_Error and Device_Error are propagated.
Implementation Permissions
-
If the associated check is too complex, an implementation need not
propagate Data_Error as part of a procedure Read (or the Read attribute)
if the value read cannot be interpreted as a value of the required
subtype.
Erroneous Execution
-
If the element read by the procedure Read (or by the Read attribute)
cannot be interpreted as a value of the required subtype, but this is
not detected and Data_Error is not propagated, then the resulting value
can be abnormal, and subsequent references to the value can lead to
erroneous execution, as explained in See section 13.9.1 Data Validity.
Go to the first, previous, next, last section, table of contents.