ENH print exceptions and exit with failure
This commit is contained in:
parent
38c766e025
commit
dc484c6557
|
@ -1,8 +1,8 @@
|
||||||
{-# LANGUAGE LambdaCase #-}
|
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
module Main (main) where
|
module Main (main) where
|
||||||
|
|
||||||
|
import qualified Data.Text.IO as TI
|
||||||
import Internal.Config
|
import Internal.Config
|
||||||
import Internal.Database.Ops
|
import Internal.Database.Ops
|
||||||
import Internal.Insert
|
import Internal.Insert
|
||||||
|
@ -157,12 +157,16 @@ runDumpAccountKeys c = do
|
||||||
runSync :: MonadUnliftIO m => FilePath -> m ()
|
runSync :: MonadUnliftIO m => FilePath -> m ()
|
||||||
runSync c = do
|
runSync c = do
|
||||||
config <- readConfig c
|
config <- readConfig c
|
||||||
migrate_ (sqlConfig config) $ do
|
handle err $ migrate_ (sqlConfig config) $ do
|
||||||
s <- getDBState config
|
s <- getDBState config
|
||||||
flip runReaderT (s $ takeDirectory c) $ do
|
flip runReaderT (s $ takeDirectory c) $ do
|
||||||
es1 <- insertBudget $ budget config
|
es1 <- insertBudget $ budget config
|
||||||
es2 <- insertStatements config
|
es2 <- insertStatements config
|
||||||
let es = es1 ++ es2
|
let es = es1 ++ es2
|
||||||
unless (null es) $ throwIO $ InsertException es
|
unless (null es) $ throwIO $ InsertException es
|
||||||
|
where
|
||||||
|
err (InsertException es) = do
|
||||||
|
liftIO $ mapM_ TI.putStrLn $ concatMap showError es
|
||||||
|
exitFailure
|
||||||
|
|
||||||
-- showBalances
|
-- showBalances
|
||||||
|
|
Loading…
Reference in New Issue