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/SlackBuilder/Update.hs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/SlackBuilder') diff --git a/src/SlackBuilder/Update.hs b/src/SlackBuilder/Update.hs index 0c7ce6f..003afb7 100644 --- a/src/SlackBuilder/Update.hs +++ b/src/SlackBuilder/Update.hs @@ -7,10 +7,13 @@ module SlackBuilder.Update , cloneFromGit , downloadWithTemplate , getAndLogLatest + , handleException , reuploadWithTemplate , updatePackageIfRequired ) where +import Control.Exception (Exception(..), SomeException(..)) +import Control.Monad.Catch (MonadCatch(..)) import Control.Monad.IO.Class (MonadIO(..)) import Control.Monad.Trans.Reader (asks) import qualified Data.ByteString as ByteString @@ -254,3 +257,9 @@ findCategory packageName = do . (currentDirectory ) in filterM directoryFilter accumulatedDirectories >>= traverse (go currentDirectory found) <&> concat + +handleException :: (MonadIO m, MonadCatch m) => SomeException -> m () +handleException slackBuilderException + = liftIO (setSGR [SetColor Foreground Dull Red]) + >> liftIO (putStrLn (displayException slackBuilderException)) + >> liftIO (setSGR [Reset]) -- cgit v1.2.3