From 5b4caa8ff75ab50b673e5d5b9ae37eb73fb21c2a Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sat, 14 Sep 2024 11:32:34 +0200 Subject: Generalize handleException --- src/Main.hs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src/Main.hs') diff --git a/src/Main.hs b/src/Main.hs index c714459..4929e7e 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -6,9 +6,8 @@ module Main ( main ) where -import Control.Exception (Exception(..), handle, SomeException(..)) import Data.Char (isNumber) -import Control.Monad.Catch (MonadThrow(..)) +import Control.Monad.Catch (MonadThrow(..), handle) import Control.Monad.IO.Class (MonadIO(..)) import qualified Data.Map as Map import Options.Applicative (execParser) @@ -257,7 +256,7 @@ autoUpdatable = up2Date :: Maybe Text -> SlackBuilderT () up2Date = \case - Nothing -> for_ autoUpdatable go + Nothing -> for_ autoUpdatable $ handle handleException . go Just packageName | Just foundPackage <- find ((packageName ==) . getField @"name") autoUpdatable -> go foundPackage @@ -268,7 +267,7 @@ up2Date = \case >> liftIO (putStrLn "") check :: SlackBuilderT () -check = for_ autoUpdatable go +check = for_ autoUpdatable $ handle handleException . go where go package = getAndLogLatest package >>= mapM_ checkUpdateAvailability @@ -290,11 +289,6 @@ main = execParser slackBuilderParser >> setSGR [Reset] >> Text.putStr (Toml.prettyTomlDecodeErrors settingsErrors) configurationFile = "config/config.toml" - handleException :: SomeException -> IO () - handleException slackBuilderException - = setSGR [SetColor Foreground Dull Red] - >> putStrLn (displayException slackBuilderException) - >> setSGR [Reset] executeCommand = \case CheckCommand -> check Up2DateCommand packageName -> up2Date packageName -- cgit v1.2.3