From e8672c4cd5b5006faac5c309c4e89d38a42ee3e2 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 13 Nov 2020 16:50:17 -0800 Subject: [PATCH] ;lib: don't catch in maybeFileModificationTime (#1390) It's overkill.. it's understood that any IO action can throw an exception, and it's best to handle them at top level, eg as Yesod does. --- hledger/Hledger/Cli/Utils.hs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hledger/Hledger/Cli/Utils.hs b/hledger/Hledger/Cli/Utils.hs index 784a9e705..ab25cb2b8 100644 --- a/hledger/Hledger/Cli/Utils.hs +++ b/hledger/Hledger/Cli/Utils.hs @@ -206,15 +206,13 @@ journalFileIsNewer Journal{jlastreadtime=tread} f = do Nothing -> False -- | Get the last modified time of the specified file, if it exists. --- Any IO exception is converted to a Nothing. maybeFileModificationTime :: FilePath -> IO (Maybe ClockTime) maybeFileModificationTime f = do exists <- doesFileExist f if exists - then (do + then do utc <- getModificationTime f return $ Just $ utcTimeToClockTime utc - ) `C.catch` \(_::C.IOException) -> return Nothing else return Nothing