From 89b8171e29410ad8f36508423adaef7eed1a80f4 Mon Sep 17 00:00:00 2001 From: Gershom Bazerman Date: Fri, 11 Feb 2022 19:59:22 -0500 Subject: [PATCH] try -> catch and display --- cabal-install/src/Distribution/Client/CmdUpdate.hs | 5 +++-- cabal-install/src/Distribution/Client/IndexUtils.hs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cabal-install/src/Distribution/Client/CmdUpdate.hs b/cabal-install/src/Distribution/Client/CmdUpdate.hs index ed3476d5545..91a0d6fd6ca 100644 --- a/cabal-install/src/Distribution/Client/CmdUpdate.hs +++ b/cabal-install/src/Distribution/Client/CmdUpdate.hs @@ -2,6 +2,7 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections #-} {-# LANGUAGE ViewPatterns #-} @@ -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 @@ -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) diff --git a/cabal-install/src/Distribution/Client/IndexUtils.hs b/cabal-install/src/Distribution/Client/IndexUtils.hs index 6339dafb298..4a734dabd67 100644 --- a/cabal-install/src/Distribution/Client/IndexUtils.hs +++ b/cabal-install/src/Distribution/Client/IndexUtils.hs @@ -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