Copyright | © 2016 Julian Ospald |
---|---|
License | BSD3 |
Maintainer | Julian Ospald <hasufell@posteo.de> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Provides error handling.
- data HPathIOException
- data RecursiveFailureHint
- = ReadContentsFailed (Path Abs) (Path Abs)
- | CreateDirFailed (Path Abs) (Path Abs)
- | CopyFileFailed (Path Abs) (Path Abs)
- | RecreateSymlinkFailed (Path Abs) (Path Abs)
- isSameFile :: HPathIOException -> Bool
- isDestinationInSource :: HPathIOException -> Bool
- isRecursiveFailure :: HPathIOException -> Bool
- isReadContentsFailed :: RecursiveFailureHint -> Bool
- isCreateDirFailed :: RecursiveFailureHint -> Bool
- isCopyFileFailed :: RecursiveFailureHint -> Bool
- isRecreateSymlinkFailed :: RecursiveFailureHint -> Bool
- throwFileDoesExist :: Path Abs -> IO ()
- throwDirDoesExist :: Path Abs -> IO ()
- throwSameFile :: Path Abs -> Path Abs -> IO ()
- sameFile :: Path Abs -> Path Abs -> IO Bool
- throwDestinationInSource :: Path Abs -> Path Abs -> IO ()
- doesFileExist :: Path Abs -> IO Bool
- doesDirectoryExist :: Path Abs -> IO Bool
- isWritable :: Path Abs -> IO Bool
- canOpenDirectory :: Path Abs -> IO Bool
- catchErrno :: [Errno] -> IO a -> IO a -> IO a
- rethrowErrnoAs :: Exception e => [Errno] -> e -> IO a -> IO a
- handleIOError :: (IOError -> IO a) -> IO a -> IO a
- bracketeer :: IO a -> (a -> IO b) -> (a -> IO b) -> (a -> IO c) -> IO c
- reactOnError :: IO a -> [(IOErrorType, IO a)] -> [(HPathIOException, IO a)] -> IO a
Types
data HPathIOException Source #
Additional generic IO exceptions that the posix functions do not provide.
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.
ReadContentsFailed (Path Abs) (Path Abs) | |
CreateDirFailed (Path Abs) (Path Abs) | |
CopyFileFailed (Path Abs) (Path Abs) | |
RecreateSymlinkFailed (Path Abs) (Path Abs) |
Exception identifiers
isSameFile :: HPathIOException -> Bool Source #
Path based functions
throwSameFile :: Path Abs -> Path Abs -> IO () Source #
Uses isSameFile
and throws SameFile
if it returns True.
sameFile :: Path Abs -> Path Abs -> IO Bool Source #
Check if the files are the same by examining device and file id. This follows symbolic links.
throwDestinationInSource Source #
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 Abs -> IO Bool Source #
Checks if the given file exists and is not a directory. Does not follow symlinks.
doesDirectoryExist :: Path Abs -> IO Bool Source #
Checks if the given file exists and is a directory. Does not follow symlinks.
canOpenDirectory :: Path Abs -> 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
:: [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.
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.
:: 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.
:: IO a | |
-> [(IOErrorType, IO a)] | reaction on IO errors |
-> [(HPathIOException, IO a)] | reaction on HPathIOException |
-> IO a |