ENH don't stop if a file is not found (or other IO nonsense)
This commit is contained in:
parent
32bbe6e16c
commit
ba19b7e92b
|
@ -299,13 +299,17 @@ insertManual
|
||||||
|
|
||||||
insertImport :: MonadUnliftIO m => Import -> MappingT m [InsertError]
|
insertImport :: MonadUnliftIO m => Import -> MappingT m [InsertError]
|
||||||
insertImport i = whenHash CTImport i [] $ \c -> do
|
insertImport i = whenHash CTImport i [] $ \c -> do
|
||||||
bounds <- asks kmStatementInterval
|
|
||||||
res <- readImport i
|
|
||||||
-- TODO this isn't efficient, the whole file will be read and maybe no
|
-- TODO this isn't efficient, the whole file will be read and maybe no
|
||||||
-- transactions will be desired
|
-- transactions will be desired
|
||||||
unlessLefts res $ \bs -> do
|
res <- tryIO $ readImport i
|
||||||
|
case res of
|
||||||
|
Right r -> unlessLefts r $ \bs -> do
|
||||||
|
bounds <- asks kmStatementInterval
|
||||||
rs <- mapM resolveTx $ filter (inMaybeBounds bounds . txDate) bs
|
rs <- mapM resolveTx $ filter (inMaybeBounds bounds . txDate) bs
|
||||||
lift $ mapM_ (insertTx c) rs
|
lift $ mapM_ (insertTx c) rs
|
||||||
|
-- If file is not found (or something else happens) then collect the
|
||||||
|
-- error try the remaining imports
|
||||||
|
Left e -> return [InsertIOError $ showT e]
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- low-level transaction stuff
|
-- low-level transaction stuff
|
||||||
|
|
|
@ -541,6 +541,7 @@ data AllocationSuberr
|
||||||
data InsertError
|
data InsertError
|
||||||
= RegexError T.Text
|
= RegexError T.Text
|
||||||
| MatchValPrecisionError Natural Natural
|
| MatchValPrecisionError Natural Natural
|
||||||
|
| InsertIOError T.Text
|
||||||
| ConversionError T.Text
|
| ConversionError T.Text
|
||||||
| LookupError LookupSuberr T.Text
|
| LookupError LookupSuberr T.Text
|
||||||
| BalanceError BalanceType CurID [RawSplit]
|
| BalanceError BalanceType CurID [RawSplit]
|
||||||
|
|
|
@ -19,6 +19,7 @@ module Internal.Utils
|
||||||
, unlessLefts
|
, unlessLefts
|
||||||
, inMaybeBounds
|
, inMaybeBounds
|
||||||
, acntPath2Text
|
, acntPath2Text
|
||||||
|
, showT
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
|
@ -280,6 +281,7 @@ showError (StatementError ts ms) = (showTx <$> ts) ++ (showMatch <$> ms)
|
||||||
showError other = (: []) $ case other of
|
showError other = (: []) $ case other of
|
||||||
(RegexError re) -> T.append "could not make regex from pattern: " re
|
(RegexError re) -> T.append "could not make regex from pattern: " re
|
||||||
(ConversionError x) -> T.append "Could not convert to rational number: " x
|
(ConversionError x) -> T.append "Could not convert to rational number: " x
|
||||||
|
(InsertIOError msg) -> T.append "IO Error: " msg
|
||||||
(MatchValPrecisionError d p) ->
|
(MatchValPrecisionError d p) ->
|
||||||
T.unwords ["Match denominator", showT d, "must be less than", showT p]
|
T.unwords ["Match denominator", showT d, "must be less than", showT p]
|
||||||
(LookupError t f) ->
|
(LookupError t f) ->
|
||||||
|
|
Loading…
Reference in New Issue