Skip to content

Commit 6f2bce2

Browse files
authored
change validation to throw instead of pre-condition to avoid crashes (#6354) (#6355)
motivation: avoid crashes changes: throw and internal error instead of pre-condition when validation fails rdar://98522178
1 parent 6c4326a commit 6f2bce2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/Workspace/Workspace.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,14 +1765,14 @@ extension Workspace {
17651765
// FIXME: This should be an ordered set.
17661766
requiredIdentities = inputIdentities.union(requiredIdentities)
17671767

1768-
let availableIdentities: Set<PackageReference> = Set(manifestsMap.map {
1768+
let availableIdentities: Set<PackageReference> = try Set(manifestsMap.map {
17691769
// FIXME: adding this guard to ensure refactoring is correct 9/21
17701770
// we only care about remoteSourceControl for this validation. it would otherwise trigger for
17711771
// a dependency is put into edit mode, which we want to deprecate anyways
17721772
if case .remoteSourceControl = $0.1.packageKind {
17731773
let effectiveURL = workspace.mirrors.effective(for: $0.1.packageLocation)
17741774
guard effectiveURL == $0.1.packageKind.locationString else {
1775-
preconditionFailure("effective url for \($0.1.packageLocation) is \(effectiveURL), different from expected \($0.1.packageKind.locationString)")
1775+
throw InternalError("effective url for \($0.1.packageLocation) is \(effectiveURL), different from expected \($0.1.packageKind.locationString)")
17761776
}
17771777
}
17781778
return PackageReference(identity: $0.key, kind: $0.1.packageKind)

0 commit comments

Comments
 (0)