base-4.1.0.0: Basic librariesSource codeContentsIndex
System.IO.Error
Portabilityportable
Stabilityprovisional
Maintainerlibraries@haskell.org
Contents
I/O errors
Classifying I/O errors
Attributes of I/O errors
Types of I/O error
IOErrorType predicates
Throwing and catching I/O errors
Description
Standard IO Errors.
Synopsis
type IOError = IOException
userError :: String -> IOError
mkIOError :: IOErrorType -> String -> Maybe Handle -> Maybe FilePath -> IOError
annotateIOError :: IOError -> String -> Maybe Handle -> Maybe FilePath -> IOError
isAlreadyExistsError :: IOError -> Bool
isDoesNotExistError :: IOError -> Bool
isAlreadyInUseError :: IOError -> Bool
isFullError :: IOError -> Bool
isEOFError :: IOError -> Bool
isIllegalOperation :: IOError -> Bool
isPermissionError :: IOError -> Bool
isUserError :: IOError -> Bool
ioeGetErrorType :: IOError -> IOErrorType
ioeGetLocation :: IOError -> String
ioeGetErrorString :: IOError -> String
ioeGetHandle :: IOError -> Maybe Handle
ioeGetFileName :: IOError -> Maybe FilePath
ioeSetErrorType :: IOError -> IOErrorType -> IOError
ioeSetErrorString :: IOError -> String -> IOError
ioeSetLocation :: IOError -> String -> IOError
ioeSetHandle :: IOError -> Handle -> IOError
ioeSetFileName :: IOError -> FilePath -> IOError
data IOErrorType
alreadyExistsErrorType :: IOErrorType
doesNotExistErrorType :: IOErrorType
alreadyInUseErrorType :: IOErrorType
fullErrorType :: IOErrorType
eofErrorType :: IOErrorType
illegalOperationErrorType :: IOErrorType
permissionErrorType :: IOErrorType
userErrorType :: IOErrorType
isAlreadyExistsErrorType :: IOErrorType -> Bool
isDoesNotExistErrorType :: IOErrorType -> Bool
isAlreadyInUseErrorType :: IOErrorType -> Bool
isFullErrorType :: IOErrorType -> Bool
isEOFErrorType :: IOErrorType -> Bool
isIllegalOperationErrorType :: IOErrorType -> Bool
isPermissionErrorType :: IOErrorType -> Bool
isUserErrorType :: IOErrorType -> Bool
ioError :: IOError -> IO a
catch
try :: IO a -> IO (Either IOError a)
modifyIOError :: (IOError -> IOError) -> IO a -> IO a
I/O errors
type IOError = IOExceptionSource

The Haskell 98 type for exceptions in the IO monad. Any I/O operation may raise an IOError instead of returning a result. For a more general type of exception, including also those that arise in pure code, see Control.Exception.Exception.

In Haskell 98, this is an opaque type.

userError :: String -> IOErrorSource

Construct an IOError value with a string describing the error. The fail method of the IO instance of the Monad class raises a userError, thus:

 instance Monad IO where 
   ...
   fail s = ioError (userError s)
mkIOError :: IOErrorType -> String -> Maybe Handle -> Maybe FilePath -> IOErrorSource
Construct an IOError of the given type where the second argument describes the error location and the third and fourth argument contain the file handle and file path of the file involved in the error if applicable.
annotateIOError :: IOError -> String -> Maybe Handle -> Maybe FilePath -> IOErrorSource
Adds a location description and maybe a file path and file handle to an IOError. If any of the file handle or file path is not given the corresponding value in the IOError remains unaltered.
Classifying I/O errors
isAlreadyExistsError :: IOError -> BoolSource
An error indicating that an IO operation failed because one of its arguments already exists.
isDoesNotExistError :: IOError -> BoolSource
An error indicating that an IO operation failed because one of its arguments does not exist.
isAlreadyInUseError :: IOError -> BoolSource
An error indicating that an IO operation failed because one of its arguments is a single-use resource, which is already being used (for example, opening the same file twice for writing might give this error).
isFullError :: IOError -> BoolSource
An error indicating that an IO operation failed because the device is full.
isEOFError :: IOError -> BoolSource
An error indicating that an IO operation failed because the end of file has been reached.
isIllegalOperation :: IOError -> BoolSource
An error indicating that an IO operation failed because the operation was not possible. Any computation which returns an IO result may fail with isIllegalOperation. In some cases, an implementation will not be able to distinguish between the possible error causes. In this case it should fail with isIllegalOperation.
isPermissionError :: IOError -> BoolSource
An error indicating that an IO operation failed because the user does not have sufficient operating system privilege to perform that operation.
isUserError :: IOError -> BoolSource
A programmer-defined error value constructed using userError.
Attributes of I/O errors
ioeGetErrorType :: IOError -> IOErrorTypeSource
ioeGetLocation :: IOError -> StringSource
ioeGetErrorString :: IOError -> StringSource
ioeGetHandle :: IOError -> Maybe HandleSource
ioeGetFileName :: IOError -> Maybe FilePathSource
ioeSetErrorType :: IOError -> IOErrorType -> IOErrorSource
ioeSetErrorString :: IOError -> String -> IOErrorSource
ioeSetLocation :: IOError -> String -> IOErrorSource
ioeSetHandle :: IOError -> Handle -> IOErrorSource
ioeSetFileName :: IOError -> FilePath -> IOErrorSource
Types of I/O error
data IOErrorType Source
An abstract type that contains a value for each variant of IOError.
show/hide Instances
alreadyExistsErrorType :: IOErrorTypeSource
I/O error where the operation failed because one of its arguments already exists.
doesNotExistErrorType :: IOErrorTypeSource
I/O error where the operation failed because one of its arguments does not exist.
alreadyInUseErrorType :: IOErrorTypeSource
I/O error where the operation failed because one of its arguments is a single-use resource, which is already being used.
fullErrorType :: IOErrorTypeSource
I/O error where the operation failed because the device is full.
eofErrorType :: IOErrorTypeSource
I/O error where the operation failed because the end of file has been reached.
illegalOperationErrorType :: IOErrorTypeSource
I/O error where the operation is not possible.
permissionErrorType :: IOErrorTypeSource
I/O error where the operation failed because the user does not have sufficient operating system privilege to perform that operation.
userErrorType :: IOErrorTypeSource
I/O error that is programmer-defined.
IOErrorType predicates
isAlreadyExistsErrorType :: IOErrorType -> BoolSource
I/O error where the operation failed because one of its arguments already exists.
isDoesNotExistErrorType :: IOErrorType -> BoolSource
I/O error where the operation failed because one of its arguments does not exist.
isAlreadyInUseErrorType :: IOErrorType -> BoolSource
I/O error where the operation failed because one of its arguments is a single-use resource, which is already being used.
isFullErrorType :: IOErrorType -> BoolSource
I/O error where the operation failed because the device is full.
isEOFErrorType :: IOErrorType -> BoolSource
I/O error where the operation failed because the end of file has been reached.
isIllegalOperationErrorType :: IOErrorType -> BoolSource
I/O error where the operation is not possible.
isPermissionErrorType :: IOErrorType -> BoolSource
I/O error where the operation failed because the user does not have sufficient operating system privilege to perform that operation.
isUserErrorType :: IOErrorType -> BoolSource
I/O error that is programmer-defined.
Throwing and catching I/O errors
ioError :: IOError -> IO aSource
Raise an IOError in the IO monad.
catch
try :: IO a -> IO (Either IOError a)Source

The construct try comp exposes IO errors which occur within a computation, and which are not fully handled.

Non-I/O exceptions are not caught by this variant; to catch all exceptions, use Control.Exception.try from Control.Exception.

modifyIOError :: (IOError -> IOError) -> IO a -> IO aSource
Catch any IOError that occurs in the computation and throw a modified version.
Produced by Haddock version 2.4.2