darcs-2.18.2: a distributed, interactive, smart revision control system

Safe Haskell | None
Language | Haskell2010

Darcs.Util.Exception

Synopsis

- firstJustIO :: [IO (Maybe a)] -> IO (Maybe a)
- catchall :: IO a -> IO a -> IO a
- clarifyErrors :: IO a -> String -> IO a
- prettyException :: SomeException -> String
- prettyError :: IOError -> String
- die :: String -> IO a
- handleOnly :: Exception e => (e -> Bool) -> IO a -> IO a -> IO a
- handleOnlyIOError :: IO a -> IO a -> IO a
- catchDoesNotExistError :: IO a -> IO a -> IO a
- handleDoesNotExistError :: IO a -> IO a -> IO a
- ifIOError :: a -> IO a -> IO a
- ifDoesNotExistError :: a -> IO a -> IO a

# Documentation

firstJustIO :: [IO (Maybe a)] -> IO (Maybe a) #

The firstJustIO is a slight modification to firstJustM: the entries in the list must be IO monad operations and the firstJustIO will silently turn any monad call that throws an exception into Nothing, basically causing it to be ignored.

catchall :: IO a -> IO a -> IO a #

clarifyErrors :: IO a -> String -> IO a #

prettyException :: SomeException -> String #

prettyError :: IOError -> String #

die :: String -> IO a #

Terminate the program with an error message.

handleOnly :: Exception e => (e -> Bool) -> IO a -> IO a -> IO a #

Handle only a those exceptions for which the predicate succeeds.

handleOnlyIOError :: IO a -> IO a -> IO a #

Handle only actual IO exceptions i.e. not "user errors" e.g. those raised by calling `fail`.

We use `fail` all over the place to signify erroneous conditions and we normally don't want to handle such errors.

catchDoesNotExistError :: IO a -> IO a -> IO a #

Handle only non-existence.

handleDoesNotExistError :: IO a -> IO a -> IO a #

Handle only non-existence.

ifIOError :: a -> IO a -> IO a #

Like `handleOnlyIOError` but restricted to returning a given value.

ifDoesNotExistError :: a -> IO a -> IO a #

Like `ifIOError` but restricted to handling non-existence.