Skip to content

Commit d52001b

Browse files
tomerdMaxDesiatov
andauthored
improve diagnostics when registry configuration is broken (#6331)
motivation: better user experience changes: catch the JSON error and wrap it with a more detailed diagnostics Co-authored-by: Max Desiatov <[email protected]>
1 parent 12e124b commit d52001b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Sources/Workspace/Workspace+Configuration.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,9 +684,12 @@ extension Workspace.Configuration {
684684
return RegistryConfiguration()
685685
}
686686

687-
let data: Data = try fileSystem.readFileContents(self.path)
688-
let decoder = JSONDecoder.makeWithDefaults()
689-
return try decoder.decode(RegistryConfiguration.self, from: data)
687+
do {
688+
let decoder = JSONDecoder.makeWithDefaults()
689+
return try decoder.decode(path: self.path, fileSystem: self.fileSystem, as: RegistryConfiguration.self)
690+
} catch {
691+
throw StringError("Failed loading registries configuration from '\(self.path)': \(error)")
692+
}
690693
}
691694

692695
public func save(_ configuration: RegistryConfiguration) throws {

0 commit comments

Comments
 (0)