summaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2024-09-14 11:32:34 +0200
committerEugen Wissner <belka@caraus.de>2024-09-14 11:32:34 +0200
commit5b4caa8ff75ab50b673e5d5b9ae37eb73fb21c2a (patch)
treea7942f83dfc00793e06a1843819a853b47dacff2 /src/Main.hs
parent3dde41e0d4848567e4a7fbcd20f43d35ce8e2dbf (diff)
downloadslackbuilder-5b4caa8ff75ab50b673e5d5b9ae37eb73fb21c2a.tar.gz
Generalize handleException
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs12
1 files changed, 3 insertions, 9 deletions
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