Skip to content

Commit 71faa6a

Browse files
committed
[DependencyResolver] Allow getDependencies to fail.
1 parent 389e49b commit 71faa6a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Sources/PackageGraph/DependencyResolver.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,12 @@ public protocol PackageContainer {
136136
/// client if necessary.
137137
///
138138
/// - Precondition: `versions.contains(version)`
139-
func getDependencies(at version: Version) -> [PackageContainerConstraint<Identifier>]
139+
/// - Throws: If the version could not be resolved; this will abort
140+
/// dependency resolution completely.
141+
//
142+
// FIXME: We should perhaps define some particularly useful error codes
143+
// here, so the resolver can handle errors more meaningfully.
144+
func getDependencies(at version: Version) throws -> [PackageContainerConstraint<Identifier>]
140145
}
141146

142147
/// An interface for resolving package containers.
@@ -398,7 +403,10 @@ struct VersionAssignmentSet<C: PackageContainer>: Sequence {
398403
//
399404
// FIXME: We should cache this too, possibly at a layer
400405
// different than above (like the entry record).
401-
for constraint in container.getDependencies(at: version) {
406+
//
407+
// FIXME: Error handling, except that we probably shouldn't have
408+
// needed to refetch the dependencies at this point.
409+
for constraint in try! container.getDependencies(at: version) {
402410
let satisfiable = result.merge(constraint)
403411
assert(satisfiable)
404412
}
@@ -619,7 +627,7 @@ public class DependencyResolver<
619627
// Get the constraints for this container version and update the
620628
// assignment to include each one.
621629
if let result = try merge(
622-
constraints: container.getDependencies(at: version),
630+
constraints: try container.getDependencies(at: version),
623631
into: assignment, subjectTo: allConstraints, excluding: allExclusions) {
624632
// We found a complete valid assignment.
625633
assert(result.checkIfValidAndComplete())

0 commit comments

Comments
 (0)