Exception handling

All file system exceptions derive from TFileSystemException (which, in turn, derives from TStandardException). The File System interface supplies a series of abstract base classes that derive from TFileSystemException and further define common situations where errors can occur.

The File System interface also defines concrete classes that derive from the specific abstract exceptions. The standard file system interface returns exceptions using these concrete classes. Other implementations of the file system can derive their own exception classes from the abstract ones provided.

These concrete classes are shown in the following table:

Concrete class Exception
TStandardFileSystemAccessDenied kNoAccess
kNoWriteAccess
kOperationNotAllowed
TStandardFileSystemTypeMismatch kNotAFile
kNotADirectory
kNotAVolume
TStandardFileSystemPositionError kNoDataBeyondThisPosition
kNotEnoughDataBeyondThisPosition
kPositionOutOfRange
TStandardFileSystemRangeLockError kNoReadAllowedInRange
kNoWriteAllowedInRange
TStandardFileSystemPermissionsError kAllowsNoAccessForOthers
kAllowsNoWriteAccessForOthers
TFileSystemEntityAlreadyExists kEntityAlreadyExists
TStandardFileSystemEntityInUse kEntityInUseByClient
kEntityInUseByFileSystem
kDirectoryContentsInUse
TStandardFileSystemEntityNotAvailable kEntityNotFound
kVolumeNotFound
kVolumeOffLine
kFileSystemNotFound
TStandardFileSystemObjectInvalid kInvalidEntity
kInvalidIterator
TStandardFileSystemVolumeAccessError kReadOnly
kWriteProtected
kNotEnoughSpace
TStandardFileSystemVolumeMountError kUnknownFileSystem
TStandardFileSystemPathNameError kPathIdenticalOnFactorRoot
kTooMuchToTruncate
kPartialTruncateMismatch
kZeroLengthName
TStandardFileSystemPathSegmentDoesNotExistError kNoVolumes
kIntermediateDirectoryDoesNotExist
kFinalSegmentDoesNotExist
kIntermediateSegmentNotADirectory
TStandardFileSystemMappedFileError kUnableToMapSpecifiedRange

Because multiple file systems can run simultaneously and a user can move your program to another file system without your knowledge, you need to be able to handle exceptions that another implementation of file system might throw. If you only catch standard exceptions (such as TStandardFileSystemObjectInvalid) you risk missing an exception. If you make sure of always catching the exceptions polymorphically (for example, also catch TFileSystemObjectInvalid) you can protect your code further. However, if you want to process the enumerated identifier in any way, you do need to catch specific standard exceptions.

CAUTION File system exceptions are not the only type of exceptions that can be thrown out of this interface. In addition to any specific exceptions that your code catches, you should close your exception list with:

    catch(...)


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker