4
* Copyright (c) 2001, 2006 Michael J. Roberts
6
* This file is part of TADS 3.
8
* This module defines classes and constants related to the File
9
* intrinsic class. In particular, this module defines the Exception
10
* subclasses thrown by File methods.
17
/* ------------------------------------------------------------------------ */
19
* File Exception classes. All File exceptions derive from FileException,
20
* to allow for generic 'catch' clauses which catch any file-related
23
class FileException: Exception
24
displayException() { "file error"; }
28
* File not found - this is thrown when attempting to open a file for
29
* reading and the file doesn't exist or can't be opened (because the user
30
* doesn't have privileges to read the file, or the file is already being
31
* used by another user, for example).
33
class FileNotFoundException: FileException
34
displayException() { "file not found"; }
38
* File creation error - this is thrown when attempting to open a file for
39
* writing and the file can't be created; this can happen because the disk
40
* or the directory is full, due to privilege failures, or due to sharing
41
* violations, among other reasons.
43
class FileCreationException: FileException
44
displayException() { "cannot create file"; }
48
* File cannot be opened - this is thrown when attempting to open a file
49
* for reading and writing but the file can't be opened. This can happen
50
* for numerous reasons: sharing violations, privilege failures, lack of
51
* space on the disk or in the directory.
53
class FileOpenException: FileException
54
displayException() { "cannot open file"; }
58
* File synchronization exception. This is thrown when an operation
59
* (such as a read or write) is attempted during normal execution on a
60
* file object that was originally opened during pre-initialization. A
61
* file object created during pre-initialization can't be used to access
62
* the file during ordinary execution, since the state of the external
63
* file might have changed since the pre-init session ended. In such
64
* cases, a new file object must be created instead.
66
class FileSyncException: FileException
67
displayException() { "file synchronization error"; }
71
* File closed - this is thrown when an operation is attempted on a file
72
* that has already been explicitly closed.
74
class FileClosedException: FileException
75
displayException() { "operation attempted on closed file"; }
79
* File I/O exception - this is thrown when a read or write operation on a
80
* file fails. This can indicate, for example, that the device containing
81
* the file is full, or that a physical media error occurred.
83
class FileIOException: FileException
84
displayException() { "file I/O error"; }
88
* File mode error - this is thrown when an attempted operation is
89
* incompatible with the file's mode. This is thrown under these
92
* - writing to a file opened for read-only access
93
*. - reading from a file opened for write-only access
94
*. - calling readFile or writeFile on a raw-mode file
95
*. - calling readBytes or writeBytes on a non-raw-mode file
97
class FileModeException: FileException
98
displayException() { "invalid file mode"; }
102
* File safety error - this is thrown when an attempted "open" operation
103
* is prohibited by the current file safety level set by the user.
105
class FileSafetyException: FileException
108
"file operation prohibited by user-specified file safety level";
113
/* export the file exceptions for use by the intrinsic class */
114
export FileNotFoundException 'File.FileNotFoundException';
115
export FileCreationException 'File.FileCreationException';
116
export FileOpenException 'File.FileOpenException';
117
export FileIOException 'File.FileIOException';
118
export FileSyncException 'File.FileSyncException';
119
export FileClosedException 'File.FileClosedException';
120
export FileModeException 'File.FileModeException';
121
export FileSafetyException 'File.FileSafetyException';