LIB/GTK: improve exceptions/error handling
This commit is contained in:
@@ -16,6 +16,7 @@ along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
--}
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# OPTIONS_HADDOCK ignore-exports #-}
|
||||
|
||||
module HSFM.GUI.Gtk.Callbacks where
|
||||
|
||||
@@ -24,14 +24,17 @@ module HSFM.GUI.Gtk.Dialogs where
|
||||
import Control.Exception
|
||||
(
|
||||
catch
|
||||
, displayException
|
||||
, throw
|
||||
, try
|
||||
, SomeException
|
||||
, IOException
|
||||
, catches
|
||||
, Handler(..)
|
||||
)
|
||||
import Control.Monad
|
||||
(
|
||||
forM
|
||||
, when
|
||||
, void
|
||||
)
|
||||
import Data.Version
|
||||
(
|
||||
@@ -209,11 +212,13 @@ withConfirmationDialog str io = do
|
||||
-- |Execute the given IO action. If the action throws exceptions,
|
||||
-- visualize them via 'showErrorDialog'.
|
||||
withErrorDialog :: IO a -> IO ()
|
||||
withErrorDialog io = do
|
||||
r <- try io
|
||||
either (\e -> showErrorDialog $ show (e :: SomeException))
|
||||
(\_ -> return ())
|
||||
r
|
||||
withErrorDialog io =
|
||||
catches (void io)
|
||||
[ Handler (\e -> showErrorDialog
|
||||
$ displayException (e :: IOException))
|
||||
, Handler (\e -> showErrorDialog
|
||||
$ displayException (e :: FmIOException))
|
||||
]
|
||||
|
||||
|
||||
-- |Asks the user which directory copy mode he wants via dialog popup
|
||||
|
||||
Reference in New Issue
Block a user