From dc484c65579089be2a17ecf2647850cc6f16667a Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Sun, 29 Jan 2023 11:35:46 -0500 Subject: [PATCH] ENH print exceptions and exit with failure --- app/Main.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index fe901e1..2cdd5f0 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -1,8 +1,8 @@ -{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} module Main (main) where +import qualified Data.Text.IO as TI import Internal.Config import Internal.Database.Ops import Internal.Insert @@ -157,12 +157,16 @@ runDumpAccountKeys c = do runSync :: MonadUnliftIO m => FilePath -> m () runSync c = do config <- readConfig c - migrate_ (sqlConfig config) $ do + handle err $ migrate_ (sqlConfig config) $ do s <- getDBState config flip runReaderT (s $ takeDirectory c) $ do es1 <- insertBudget $ budget config es2 <- insertStatements config let es = es1 ++ es2 unless (null es) $ throwIO $ InsertException es + where + err (InsertException es) = do + liftIO $ mapM_ TI.putStrLn $ concatMap showError es + exitFailure -- showBalances