hpath-0.9.2: Support for well-typed paths
Copyright© 2016 Julian Ospald
LicenseBSD3
MaintainerJulian Ospald <hasufell@posteo.de>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

HPath.IO.Errors

Description

Provides error handling.

Synopsis

Types

data RecursiveFailureHint Source #

A type for giving failure hints on recursive failure, which allows to programmatically make choices without examining the weakly typed I/O error attributes (like ioeGetFileName).

The first argument to the data constructor is always the source and the second the destination.

Exception identifiers

Path based functions

throwFileDoesExist :: Path b -> IO () Source #

Throws AlreadyExists IOError if file exists.

throwDirDoesExist :: Path b -> IO () Source #

Throws AlreadyExists IOError if directory exists.

throwSameFile :: Path b1 -> Path b2 -> IO () Source #

Uses isSameFile and throws SameFile if it returns True.

sameFile :: Path b1 -> Path b2 -> IO Bool Source #

Check if the files are the same by examining device and file id. This follows symbolic links.

throwDestinationInSource Source #

Arguments

:: Path b1

source dir

-> Path b2

full destination, dirname dest must exist

-> IO () 

Checks whether the destination directory is contained within the source directory by comparing the device+file ID of the source directory with all device+file IDs of the parent directories of the destination.

doesFileExist :: Path b -> IO Bool Source #

Checks if the given file exists and is not a directory. Does not follow symlinks.

doesDirectoryExist :: Path b -> IO Bool Source #

Checks if the given file exists and is a directory. Does not follow symlinks.

isWritable :: Path b -> IO Bool Source #

Checks whether a file or folder is writable.

canOpenDirectory :: Path b -> IO Bool Source #

Checks whether the directory at the given path exists and can be opened. This invokes openDirStream which follows symlinks.

Error handling functions

catchErrno Source #

Arguments

:: [Errno]

errno to catch

-> IO a

action to try, which can raise an IOException

-> IO a

action to carry out in case of an IOException and if errno matches

-> IO a 

Carries out an action, then checks if there is an IOException and a specific errno. If so, then it carries out another action, otherwise it rethrows the error.

rethrowErrnoAs Source #

Arguments

:: Exception e 
=> [Errno]

errno to catch

-> e

rethrow as if errno matches

-> IO a

action to try

-> IO a 

Execute the given action and retrow IO exceptions as a new Exception that have the given errno. If errno does not match the exception is rethrown as is.

handleIOError :: (IOError -> IO a) -> IO a -> IO a Source #

Like catchIOError, with arguments swapped.

bracketeer Source #

Arguments

:: IO a

computation to run first

-> (a -> IO b)

computation to run last, when no exception was raised

-> (a -> IO b)

computation to run last, when an exception was raised

-> (a -> IO c)

computation to run in-between

-> IO c 

Like bracket, but allows to have different clean-up actions depending on whether the in-between computation has raised an exception or not.

reactOnError Source #

Arguments

:: IO a 
-> [(IOErrorType, IO a)]

reaction on IO errors

-> [(HPathIOException, IO a)]

reaction on HPathIOException

-> IO a