LIB: improve exception handling

This commit is contained in:
hasufell
2016-04-06 04:27:02 +02:00
parent 038b0d0377
commit 17407860f4
2 changed files with 16 additions and 1 deletions

View File

@@ -199,6 +199,15 @@ catchErrno en a1 a2 =
else ioError e
-- |Execute the given action and retrow IO exceptions that have the given errno.
rethrowErrnoAs :: Errno -- ^ errno to catch
-> FmIOException -- ^ rethrow as
-> IO a -- ^ action to try
-> IO a
rethrowErrnoAs en fmex action = catchErrno en action (throw fmex)
-- |Like `catchIOError`, with arguments swapped.
handleIOError :: (IOError -> IO a) -> IO a -> IO a
handleIOError a1 a2 = catchIOError a2 a1