Skip to content

Commit

Permalink
try -> catch and display
Browse files Browse the repository at this point in the history
  • Loading branch information
gbaz committed Feb 12, 2022
1 parent dcf4bd6 commit 89b8171
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions cabal-install/src/Distribution/Client/CmdUpdate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ViewPatterns #-}

Expand Down Expand Up @@ -43,7 +44,7 @@ import Distribution.Client.Setup
import Distribution.Simple.Flag
( fromFlagOrDefault )
import Distribution.Simple.Utils
( die', notice, wrapText, writeFileAtomic, noticeNoWrap )
( die', notice, wrapText, writeFileAtomic, noticeNoWrap, warn )
import Distribution.Verbosity
( normal, lessVerbose )
import Distribution.Client.IndexUtils.Timestamp
Expand Down Expand Up @@ -210,7 +211,7 @@ updateRepo verbosity _updateFlags repoCtxt (repo, indexState) = do
case updated of
Sec.NoUpdates -> do
now <- getCurrentTime
_ <- try $ setModificationTime (indexBaseName repo <.> "tar") now :: IO (Either SomeException ())
setModificationTime (indexBaseName repo <.> "tar") now `catch` (\(e :: SomeException) -> warn verbosity $ "Could not set modification time of index tarball -- " ++ show e)
noticeNoWrap verbosity $
"Package list of " ++ prettyShow rname ++
" is up to date at index-state " ++ prettyShow (IndexStateTime current_ts)
Expand Down
2 changes: 1 addition & 1 deletion cabal-install/src/Distribution/Client/IndexUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ readRepoIndex verbosity repoCtxt repo idxState =
handleNotFound $ do
when (isRepoRemote repo) $ warnIfIndexIsOld =<< getIndexFileAge repo
-- note that if this step fails due to a bad repocache, the the procedure can still succeed by reading from the existing cache, which is updated regardless.
_ <- try $ updateRepoIndexCache verbosity (RepoIndex repoCtxt repo) :: IO (Either SomeException ())
updateRepoIndexCache verbosity (RepoIndex repoCtxt repo) `catch` (\(e :: SomeException) -> warn verbosity $ "unable to update the repo index cache -- " ++ displayException e)
readPackageIndexCacheFile verbosity mkAvailablePackage
(RepoIndex repoCtxt repo)
idxState
Expand Down

0 comments on commit 89b8171

Please sign in to comment.