Commit 49b31ed7 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Annotate exceptions in downloading packages

Download errors are now put into the residual install plan, like other
build errors.

Fixes issue #3387
parent db785667
......@@ -76,7 +76,6 @@ import Data.Maybe
import System.FilePath
import System.IO
import System.Directory
import System.Exit (ExitCode)
------------------------------------------------------------------------------
......@@ -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
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment