Skip to content

Commit

Permalink
Annotate exceptions in downloading packages
Browse files Browse the repository at this point in the history
Download errors are now put into the residual install plan, like other
build errors.

Fixes issue #3387
  • Loading branch information
dcoutts committed Jul 26, 2016
1 parent 4efb6af commit 0fedb42
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions cabal-install/Distribution/Client/ProjectBuilding.hs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ import Data.Maybe
import System.FilePath
import System.IO
import System.Directory
import System.Exit (ExitCode)


------------------------------------------------------------------------------
Expand Down Expand Up @@ -669,7 +668,8 @@ rebuildTarget verbosity
unexpectedState = error "rebuildTarget: unexpected package status"

downloadPhase = do
downsrcloc <- waitAsyncPackageDownload verbosity downloadMap pkg
downsrcloc <- annotateFailure DownloadFailed $
waitAsyncPackageDownload verbosity downloadMap pkg
case downsrcloc of
DownloadedTarball tarball -> unpackTarballPhase tarball
--TODO: [nice to have] git/darcs repos etc
Expand Down Expand Up @@ -1261,8 +1261,16 @@ buildInplaceUnpackedPackage verbosity
annotateFailure :: (SomeException -> BuildFailure) -> IO a -> IO a
annotateFailure annotate action =
action `catches`
[ Handler $ \ioe -> handler (ioe :: IOException)
, Handler $ \exit -> handler (exit :: ExitCode)
-- It's not just IOException and ExitCode we have to deal with, there's
-- lots, including exceptions from the hackage-security and tar packages.
-- So we take the strategy of catching everything except async exceptions.
[
#if MIN_VERSION_base(4,7,0)
Handler $ \async -> throwIO (async :: SomeAsyncException)
#else
Handler $ \async -> throwIO (async :: AsyncException)
#endif
, Handler $ \other -> handler (other :: SomeException)
]
where
handler :: Exception e => e -> IO a
Expand Down

0 comments on commit 0fedb42

Please sign in to comment.