@@ -51,7 +51,7 @@ type SequentialUpgradeResult =
51
51
}
52
52
53
53
data PackageSets a
54
- = UpgradeAtomic PackageSet Version ChangeSet (Either String (Maybe PackageSet ) -> a )
54
+ = UpgradeAtomic PackageSet Version ChangeSet (Either String (Either String PackageSet ) -> a )
55
55
| UpgradeSequential PackageSet Version ChangeSet (Either String (Maybe SequentialUpgradeResult ) -> a )
56
56
57
57
derive instance Functor PackageSets
@@ -65,7 +65,7 @@ _packageSets = Proxy
65
65
-- | Upgrade the given package set using the provided compiler version and set
66
66
-- | of changes. If any change fails, then the upgrade is aborted and the
67
67
-- | 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 )
69
69
upgradeAtomic oldSet compiler changes = Run .lift _packageSets (UpgradeAtomic oldSet compiler changes identity) >>= Except .rethrow
70
70
71
71
-- | 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
74
74
upgradeSequential :: forall r . PackageSet -> Version -> ChangeSet -> Run (PACKAGE_SETS + EXCEPT String + r ) (Maybe SequentialUpgradeResult )
75
75
upgradeSequential oldSet compiler changes = do
76
76
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 }
79
79
80
80
interpret :: forall r a . (PackageSets ~> Run r ) -> Run (PACKAGE_SETS + r ) a -> Run r a
81
81
interpret handler = Run .interpret (Run .on _packageSets handler Run .send)
@@ -105,21 +105,24 @@ handle env = case _ of
105
105
MissingCompiler -> Except .throw $ printMissingCompiler compiler
106
106
UnknownError error -> Except .throw $ printUnknownError error
107
107
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
+ ]
110
112
Right _ -> pure unit
111
113
112
114
attemptChanges compiler oldSet changes >>= case _ of
113
115
Left compilerError -> case compilerError of
114
116
MissingCompiler -> Except .throw $ printMissingCompiler compiler
115
117
UnknownError error -> Except .throw $ printUnknownError error
116
118
CompilationError errors -> do
117
- Log .info $ printCompilationError errors
118
- pure Nothing
119
+ let printed = printCompilationError errors
120
+ Log .warn printed
121
+ pure (Left printed)
119
122
Right pending -> do
120
123
newSet <- updatePackageSetMetadata compiler { previous: oldSet, pending } changes
121
124
validatePackageSet newSet
122
- pure (Just newSet)
125
+ pure (Right newSet)
123
126
124
127
UpgradeSequential oldSet@(PackageSet { packages }) compiler changes reply -> reply <$> Except .runExcept do
125
128
Log .info $ " Performing sequential upgrade of package set " <> Version .print (un PackageSet oldSet).version
0 commit comments