;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:
Simon Michael 2020-11-13 16:50:17 -08:00
parent 3651a5f5f4
commit e8672c4cd5

View File

@ -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