Skip to content

Commit 85b4149

Browse files
committed
Remove throws, use completion pattern exclusively
1 parent 729c6d3 commit 85b4149

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

Sources/PackageLoading/ManifestLoader.swift

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ public final class ManifestLoader: ManifestLoaderProtocol {
515515
fileSystem: FileSystem,
516516
observabilityScope: ObservabilityScope,
517517
completion: @escaping (Result<ManifestJSONParser.Result, Error>) -> Void
518-
) throws {
518+
) {
519519
let cache = self.databaseCacheDir.map { cacheDir -> SQLiteBackedCache<EvaluationResult> in
520520
let path = Self.manifestCacheDBPath(cacheDir)
521521
var configuration = SQLiteBackedCacheConfiguration()
@@ -532,14 +532,19 @@ public final class ManifestLoader: ManifestLoaderProtocol {
532532
// TODO: we could wrap the failure here with diagnostics if it wasn't optional throughout
533533
defer { try? cache?.close() }
534534

535-
let key = try CacheKey(
536-
packageIdentity: packageIdentity,
537-
manifestPath: path,
538-
toolsVersion: toolsVersion,
539-
env: ProcessEnv.vars,
540-
swiftpmVersion: SwiftVersion.currentVersion.displayString,
541-
fileSystem: fileSystem
542-
)
535+
let key : CacheKey
536+
do {
537+
key = try CacheKey(
538+
packageIdentity: packageIdentity,
539+
manifestPath: path,
540+
toolsVersion: toolsVersion,
541+
env: ProcessEnv.vars,
542+
swiftpmVersion: SwiftVersion.currentVersion.displayString,
543+
fileSystem: fileSystem
544+
)
545+
} catch {
546+
return completion(.failure(error))
547+
}
543548

544549
do {
545550
// try to get it from the cache
@@ -556,7 +561,7 @@ public final class ManifestLoader: ManifestLoaderProtocol {
556561
}
557562
} catch {
558563
observabilityScope.emit(warning: "failed loading cached manifest for '\(key.packageIdentity)': \(error)")
559-
completion(.failure(error))
564+
return completion(.failure(error))
560565
}
561566

562567
// shells out and compiles the manifest, finally output a JSON

0 commit comments

Comments
 (0)