Skip to content

Commit 30db95d

Browse files
Thread through package set errors (#661)
1 parent 1b9fc7d commit 30db95d

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

app/src/App/API.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@ packageSetUpdate payload = do
204204
let changeSet = candidates.accepted <#> maybe Remove Update
205205
Comment.comment "Attempting to build package set update."
206206
PackageSets.upgradeAtomic latestPackageSet (fromMaybe prevCompiler payload.compiler) changeSet >>= case _ of
207-
Nothing ->
208-
Except.throw "The package set produced from this suggested update does not compile."
209-
Just packageSet -> do
207+
Left error ->
208+
Except.throw $ "The package set produced from this suggested update does not compile:\n\n" <> error
209+
Right packageSet -> do
210210
let commitMessage = PackageSets.commitMessage latestPackageSet changeSet (un PackageSet packageSet).version
211211
Registry.writePackageSet packageSet commitMessage
212212
Comment.comment "Built and released a new package set! Now mirroring to the package-sets repo..."

app/src/App/Effect/PackageSets.purs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type SequentialUpgradeResult =
5151
}
5252

5353
data 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

5757
derive 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)
6969
upgradeAtomic 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
7474
upgradeSequential :: forall r. PackageSet -> Version -> ChangeSet -> Run (PACKAGE_SETS + EXCEPT String + r) (Maybe SequentialUpgradeResult)
7575
upgradeSequential 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

8080
interpret :: forall r a. (PackageSets ~> Run r) -> Run (PACKAGE_SETS + r) a -> Run r a
8181
interpret 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

app/test/Test/Assert/Run.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ handlePackageSetsMock :: forall r a. PackageSets a -> Run r a
217217
handlePackageSetsMock = case _ of
218218
-- FIXME: Actually reply with a package set with a pure upgrade
219219
UpgradeAtomic _packageSet _compilerVersion _changeSet reply -> do
220-
pure $ reply $ Right Nothing
220+
pure $ reply $ Right $ Left ""
221221
-- FIXME: Actually reply with a package sequential upgrade result
222222
UpgradeSequential packageSet _compilerVersion changeSet reply ->
223223
pure $ reply $ Right $ Just { failed: changeSet, succeeded: changeSet, result: packageSet }

0 commit comments

Comments
 (0)