mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-18 17:57:11 +03:00
;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.
This commit is contained in:
parent
3651a5f5f4
commit
e8672c4cd5
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user