Commit 51da3c74 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Add better exception handling in new-build

When executing the install plan, the various failures are supposed to be
caught and put into the residual install plan. This adds the main cases
for that, including the configure and build cases. Download is still not
covered.

This is a step towards better reporting of what failed when there are
failures in deps etc.
parent a93e77f7
......@@ -52,10 +52,12 @@ buildAction (configFlags, configExFlags, installFlags, haddockFlags)
printPlan verbosity buildCtx
unless (buildSettingDryRun buildSettings) $
runProjectBuildPhase
verbosity
buildCtx
unless (buildSettingDryRun buildSettings) $ do
_plan <- runProjectBuildPhase
verbosity
buildCtx
--TODO: [required eventually] report on build failures in residual plan
return ()
where
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
......
......@@ -56,10 +56,12 @@ replAction (configFlags, configExFlags, installFlags, haddockFlags)
printPlan verbosity buildCtx
unless (buildSettingDryRun buildSettings) $
runProjectBuildPhase
verbosity
buildCtx
unless (buildSettingDryRun buildSettings) $ do
_plan <- runProjectBuildPhase
verbosity
buildCtx
--TODO: [required eventually] report on build failures in residual plan
return ()
where
verbosity = fromFlagOrDefault normal (configVerbosity configFlags)
......
......@@ -1129,7 +1129,8 @@ buildInplaceUnpackedPackage verbosity
-- Configure phase
--
whenReConfigure $ do
setup configureCommand configureFlags []
annotateFailure ConfigureFailed $
setup configureCommand configureFlags []
invalidatePackageRegFileMonitor packageFileMonitor
updatePackageConfigFileMonitor packageFileMonitor srcdir pkg
......@@ -1143,7 +1144,8 @@ buildInplaceUnpackedPackage verbosity
whenRebuild $ do
timestamp <- beginUpdateFileMonitor
setup buildCommand buildFlags buildArgs
annotateFailure BuildFailed $
setup buildCommand buildFlags buildArgs
--TODO: [required eventually] this doesn't track file
--non-existence, so we could fail to rebuild if someone
......@@ -1154,7 +1156,7 @@ buildInplaceUnpackedPackage verbosity
pkg buildStatus
allSrcFiles buildSuccess
ipkgs <- whenReRegister $ do
ipkgs <- whenReRegister $ annotateFailure InstallFailed $ do
-- Register locally
ipkgs <- if pkgRequiresRegistration pkg
then do
......@@ -1228,10 +1230,12 @@ buildInplaceUnpackedPackage verbosity
-- Repl phase
--
whenRepl $
annotateFailure BuildFailed $
setup replCommand replFlags replArgs
-- Haddock phase
whenHaddock $
annotateFailure BuildFailed $
setup haddockCommand haddockFlags []
return (BuildSuccess ipkgs buildSuccess)
......@@ -1315,8 +1319,12 @@ annotateFailure annotate action =
]
where
handler :: Exception e => e -> IO a
handler = throwIO . annotate . show
--TODO: [nice to have] use displayException when available
handler = throwIO . annotate
#if MIN_VERSION_base(4,8,0)
. displayException
#else
. show
#endif
withTempInstalledPackageInfoFiles :: Verbosity -> FilePath
......
......@@ -21,6 +21,7 @@ module Distribution.Client.ProjectConfig (
-- * Packages within projects
ProjectPackageLocation(..),
BadPackageLocations(..),
BadPackageLocation(..),
BadPackageLocationMatch(..),
findProjectPackages,
......
......@@ -192,16 +192,14 @@ runProjectPreBuildPhase
--
runProjectBuildPhase :: Verbosity
-> ProjectBuildContext
-> IO ()
runProjectBuildPhase verbosity ProjectBuildContext {..} = do
_ <- rebuildTargets verbosity
distDirLayout
elaboratedPlan
elaboratedShared
pkgsBuildStatus
buildSettings
--TODO return the result plan and use it for other status reporting
return ()
-> IO ElaboratedInstallPlan
runProjectBuildPhase verbosity ProjectBuildContext {..} =
rebuildTargets verbosity
distDirLayout
elaboratedPlan
elaboratedShared
pkgsBuildStatus
buildSettings
-- Note that it is a deliberate design choice that the 'buildTargets' is
-- not passed to phase 1, and the various bits of input config is not
......
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