System.IO.Error (original) (raw)
type IOError = IOException Source #
The Haskell 2010 type for exceptions in the [IO](System-IO.html#t:IO "System.IO") monad. Any I/O operation may raise an [IOException](Control-Exception.html#t:IOException "Control.Exception") instead of returning a result. For a more general type of exception, including also those that arise in pure code, see [Exception](Control-Exception.html#v:Exception "Control.Exception").
In Haskell 2010, this is an opaque type.
isAlreadyInUseError :: IOError -> Bool Source #
An error indicating that an [IO](System-IO.html#t:IO "System.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).
isPermissionError :: IOError -> Bool Source #
An error indicating that an [IO](System-IO.html#t:IO "System.IO") operation failed because the user does not have sufficient operating system privilege to perform that operation.
Attributes of I/O errorsTypes of I/O error
resourceVanishedErrorType :: IOErrorType Source #
I/O error where the operation failed because the resource vanished. This happens when, for example, attempting to write to a closed socket or attempting to write to a named pipe that was deleted.
Since: base-4.14.0.0
IOErrorType predicatesThrowing and catching I/O errors
catchIOError :: IO a -> (IOError -> IO a) -> IO a Source #
The [catchIOError](System-IO-Error.html#v:catchIOError "System.IO.Error") function establishes a handler that receives any[IOException](Control-Exception.html#t:IOException "Control.Exception") raised in the action protected by [catchIOError](System-IO-Error.html#v:catchIOError "System.IO.Error"). An [IOException](Control-Exception.html#t:IOException "Control.Exception") is caught by the most recent handler established by one of the exception handling functions. These handlers are not selective: all [IOException](Control-Exception.html#t:IOException "Control.Exception")s are caught. Exception propagation must be explicitly provided in a handler by re-raising any unwanted exceptions. For example, in
f = catchIOError g (\e -> if IO.isEOFError e then return [] else ioError e)
the function f returns [] when an end-of-file exception (cf. [isEOFError](System-IO-Error.html#v:isEOFError "System.IO.Error")) occurs in g; otherwise, the exception is propagated to the next outer handler.
When an exception propagates outside the main program, the Haskell system prints the associated [IOException](Control-Exception.html#t:IOException "Control.Exception") value and exits the program.
Non-I/O exceptions are not caught by this variant; to catch all exceptions, use [catch](Control-Exception.html#v:catch "Control.Exception") from Control.Exception.
Since: base-4.4.0.0