@@ -51,7 +51,7 @@ type SequentialUpgradeResult =
5151 }
5252
5353data PackageSets a
54- = UpgradeAtomic PackageSet Version ChangeSet (Either String (Maybe PackageSet ) -> a )
54+ = UpgradeAtomic PackageSet Version ChangeSet (Either String (Either String PackageSet ) -> a )
5555 | UpgradeSequential PackageSet Version ChangeSet (Either String (Maybe SequentialUpgradeResult ) -> a )
5656
5757derive instance Functor PackageSets
@@ -65,7 +65,7 @@ _packageSets = Proxy
6565-- | Upgrade the given package set using the provided compiler version and set
6666-- | of changes. If any change fails, then the upgrade is aborted and the
6767-- | unsuccessful changes are returned.
68- upgradeAtomic :: forall r . PackageSet -> Version -> ChangeSet -> Run (PACKAGE_SETS + EXCEPT String + r ) (Maybe PackageSet )
68+ upgradeAtomic :: forall r . PackageSet -> Version -> ChangeSet -> Run (PACKAGE_SETS + EXCEPT String + r ) (Either String PackageSet )
6969upgradeAtomic oldSet compiler changes = Run .lift _packageSets (UpgradeAtomic oldSet compiler changes identity) >>= Except .rethrow
7070
7171-- | Upgrade the given package set using the provided compiler version and set
@@ -74,8 +74,8 @@ upgradeAtomic oldSet compiler changes = Run.lift _packageSets (UpgradeAtomic old
7474upgradeSequential :: forall r . PackageSet -> Version -> ChangeSet -> Run (PACKAGE_SETS + EXCEPT String + r ) (Maybe SequentialUpgradeResult )
7575upgradeSequential oldSet compiler changes = do
7676 upgradeAtomic oldSet compiler changes >>= case _ of
77- Just result -> pure $ Just { failed: Map .empty, succeeded: changes, result }
78- Nothing -> Run .lift _packageSets ( UpgradeSequential oldSet compiler changes identity) >>= Except .rethrow
77+ Left _ -> Run .lift _packageSets ( UpgradeSequential oldSet compiler changes identity) >>= Except .rethrow
78+ Right result -> pure $ Just { failed: Map .empty, succeeded: changes, result }
7979
8080interpret :: forall r a . (PackageSets ~> Run r ) -> Run (PACKAGE_SETS + r ) a -> Run r a
8181interpret handler = Run .interpret (Run .on _packageSets handler Run .send)
@@ -105,21 +105,24 @@ handle env = case _ of
105105 MissingCompiler -> Except .throw $ printMissingCompiler compiler
106106 UnknownError error -> Except .throw $ printUnknownError error
107107 CompilationError errors -> do
108- Log .error $ printCompilationError errors
109- Except .throw " Compilation failed, but the starting package set must compile in order to process a batch."
108+ Except .throw $ Array .fold
109+ [ " Compilation failed, but the starting package set must compile in order to process a batch:\n\n "
110+ , printCompilationError errors
111+ ]
110112 Right _ -> pure unit
111113
112114 attemptChanges compiler oldSet changes >>= case _ of
113115 Left compilerError -> case compilerError of
114116 MissingCompiler -> Except .throw $ printMissingCompiler compiler
115117 UnknownError error -> Except .throw $ printUnknownError error
116118 CompilationError errors -> do
117- Log .info $ printCompilationError errors
118- pure Nothing
119+ let printed = printCompilationError errors
120+ Log .warn printed
121+ pure (Left printed)
119122 Right pending -> do
120123 newSet <- updatePackageSetMetadata compiler { previous: oldSet, pending } changes
121124 validatePackageSet newSet
122- pure (Just newSet)
125+ pure (Right newSet)
123126
124127 UpgradeSequential oldSet@(PackageSet { packages }) compiler changes reply -> reply <$> Except .runExcept do
125128 Log .info $ " Performing sequential upgrade of package set " <> Version .print (un PackageSet oldSet).version
0 commit comments