;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
|
Nothing -> False
|
||||||
|
|
||||||
-- | Get the last modified time of the specified file, if it exists.
|
-- | 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 :: FilePath -> IO (Maybe ClockTime)
|
||||||
maybeFileModificationTime f = do
|
maybeFileModificationTime f = do
|
||||||
exists <- doesFileExist f
|
exists <- doesFileExist f
|
||||||
if exists
|
if exists
|
||||||
then (do
|
then do
|
||||||
utc <- getModificationTime f
|
utc <- getModificationTime f
|
||||||
return $ Just $ utcTimeToClockTime utc
|
return $ Just $ utcTimeToClockTime utc
|
||||||
) `C.catch` \(_::C.IOException) -> return Nothing
|
|
||||||
else
|
else
|
||||||
return Nothing
|
return Nothing
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user