LIB/GTK: use throwIO instead of throw

This commit is contained in:
Julian Ospald 2016-05-09 11:34:02 +02:00
parent 173c4cbddd
commit dc457eb168
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
4 changed files with 32 additions and 32 deletions

View File

@ -148,25 +148,25 @@ isDirDoesExist _ = False
throwFileDoesExist :: Path Abs -> IO ()
throwFileDoesExist fp =
whenM (doesFileExist fp) (throw . FileDoesExist
whenM (doesFileExist fp) (throwIO . FileDoesExist
. P.fromAbs $ fp)
throwDirDoesExist :: Path Abs -> IO ()
throwDirDoesExist fp =
whenM (doesDirectoryExist fp) (throw . DirDoesExist
whenM (doesDirectoryExist fp) (throwIO . DirDoesExist
. P.fromAbs $ fp)
throwFileDoesNotExist :: Path Abs -> IO ()
throwFileDoesNotExist fp =
unlessM (doesFileExist fp) (throw . FileDoesNotExist
unlessM (doesFileExist fp) (throwIO . FileDoesNotExist
. P.fromAbs $ fp)
throwDirDoesNotExist :: Path Abs -> IO ()
throwDirDoesNotExist fp =
unlessM (doesDirectoryExist fp) (throw . DirDoesNotExist
unlessM (doesDirectoryExist fp) (throwIO . DirDoesNotExist
. P.fromAbs $ fp)
@ -176,7 +176,7 @@ throwSameFile :: Path Abs
-> IO ()
throwSameFile fp1 fp2 =
whenM (sameFile fp1 fp2)
(throw $ SameFile (P.fromAbs fp1) (P.fromAbs fp2))
(throwIO $ SameFile (P.fromAbs fp1) (P.fromAbs fp2))
-- |Check if the files are the same by examining device and file id.
@ -211,7 +211,7 @@ throwDestinationInSource source dest = do
sid <- fmap (\x -> (PF.deviceID x, PF.fileID x))
$ PF.getFileStatus (P.fromAbs source)
when (elem sid dids)
(throw $ DestinationInSource (P.fromAbs dest)
(throwIO $ DestinationInSource (P.fromAbs dest)
(P.fromAbs source))
@ -256,7 +256,7 @@ canOpenDirectory fp =
throwCantOpenDirectory :: Path Abs -> IO ()
throwCantOpenDirectory fp =
unlessM (canOpenDirectory fp)
(throw . Can'tOpenDirectory . P.fromAbs $ fp)
(throwIO . Can'tOpenDirectory . P.fromAbs $ fp)
@ -289,7 +289,7 @@ rethrowErrnoAs :: Exception e
-> e -- ^ rethrow as if errno matches
-> IO a -- ^ action to try
-> IO a
rethrowErrnoAs en fmex action = catchErrno en action (throw fmex)
rethrowErrnoAs en fmex action = catchErrno en action (throwIO fmex)

View File

@ -46,7 +46,7 @@ import Control.Exception
(
bracket
, bracketOnError
, throw
, throwIO
)
import Control.Monad
(
@ -420,7 +420,7 @@ _copyFile sflags dflags from to
then return $ fromIntegral totalsize
else do rsize <- SPB.fdWriteBuf dfd buf size
-- TODO: switch to IOError?
when (rsize /= size) (throw . CopyFailed $ "wrong size!")
when (rsize /= size) (throwIO . CopyFailed $ "wrong size!")
write' sfd dfd buf (totalsize + fromIntegral size)

View File

@ -28,7 +28,7 @@ import Control.Concurrent.STM
)
import Control.Exception
(
throw
throwIO
)
import Control.Monad
(
@ -340,7 +340,7 @@ del items@(_:_) _ _ = withErrorDialog $ do
withConfirmationDialog cmsg
$ forM_ items $ \item -> easyDelete . path $ item
del _ _ _ = withErrorDialog
. throw $ InvalidOperation
. throwIO $ InvalidOperation
"Operation not supported on multiple files"
@ -355,7 +355,7 @@ moveInit items@(_:_) mygui _ = do
popStatusbar mygui
void $ pushStatusBar mygui sbmsg
moveInit _ _ _ = withErrorDialog
. throw $ InvalidOperation
. throwIO $ InvalidOperation
"No file selected!"
-- |Supposed to be used with 'withRows'. Initializes a file copy operation.
@ -369,7 +369,7 @@ copyInit items@(_:_) mygui _ = do
popStatusbar mygui
void $ pushStatusBar mygui sbmsg
copyInit _ _ _ = withErrorDialog
. throw $ InvalidOperation
. throwIO $ InvalidOperation
"No file selected!"
@ -434,7 +434,7 @@ renameF [item] _ _ = withErrorDialog $ do
HSFM.FileSystem.FileOperations.renameFile (path item)
((P.dirname $ path item) P.</> fn)
renameF _ _ _ = withErrorDialog
. throw $ InvalidOperation
. throwIO $ InvalidOperation
"Operation not supported on multiple files"
@ -468,7 +468,7 @@ execute :: [Item] -> MyGUI -> MyView -> IO ()
execute [item] _ _ = withErrorDialog $
void $ executeFile (path item) []
execute _ _ _ = withErrorDialog
. throw $ InvalidOperation
. throwIO $ InvalidOperation
"Operation not supported on multiple files"
@ -485,7 +485,7 @@ open [item] mygui myview = withErrorDialog $
open (FileLikeList fs) _ _ = withErrorDialog $
forM_ fs $ \f -> void $ openFile . path $ f
open _ _ _ = withErrorDialog
. throw $ InvalidOperation
. throwIO $ InvalidOperation
"Operation not supported on multiple files"

View File

@ -24,7 +24,7 @@ module HSFM.GUI.Gtk.Dialogs where
import Control.Exception
(
displayException
, throw
, throwIO
, IOException
, catches
, Handler(..)
@ -153,7 +153,7 @@ fileCollisionDialog t = do
forM mfn $ \fn -> do
pfn <- P.parseFn (P.userStringToFP fn)
return $ Rename pfn
_ -> throw UnknownDialogButton
_ -> throwIO UnknownDialogButton
renameDialog :: ByteString -> IO (Maybe FCollisonMode)
@ -178,7 +178,7 @@ renameDialog t = do
forM mfn $ \fn -> do
pfn <- P.parseFn (P.userStringToFP fn)
return $ Rename pfn
_ -> throw UnknownDialogButton
_ -> throwIO UnknownDialogButton
-- |Shows the about dialog from the help menu.
@ -250,7 +250,7 @@ textInputDialog title inittext = do
-- TODO: make this more safe
ResponseUser 0 -> Just <$> entryGetText entry
ResponseUser 1 -> return Nothing
_ -> throw UnknownDialogButton
_ -> throwIO UnknownDialogButton
widgetDestroy chooserDialog
return ret