Skip to content

Commit 2eefd53

Browse files
authored
Provide more verbose error information when failing to index plists, xcdatamodels, and xibs (#981)
1 parent 4120074 commit 2eefd53

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

Sources/Indexer/InfoPlistIndexer.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import SourceGraph
55
import SystemPackage
66

77
final class InfoPlistIndexer: Indexer {
8+
enum PlistError: Error {
9+
case failedToParse(path: FilePath, underlyingError: Error)
10+
}
811
private let infoPlistFiles: Set<FilePath>
912
private let graph: SynchronizedSourceGraph
1013
private let logger: ContextualLogger
@@ -24,9 +27,13 @@ final class InfoPlistIndexer: Indexer {
2427
guard let self else { return }
2528

2629
let elapsed = try Benchmark.measure {
27-
try InfoPlistParser(path: path)
28-
.parse()
29-
.forEach { self.graph.add($0) }
30+
do {
31+
try InfoPlistParser(path: path)
32+
.parse()
33+
.forEach { self.graph.add($0) }
34+
} catch {
35+
throw PlistError.failedToParse(path: path, underlyingError: error)
36+
}
3037
}
3138

3239
logger.debug("\(path.string) (\(elapsed)s)")

Sources/Indexer/XCDataModelIndexer.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import SourceGraph
55
import SystemPackage
66

77
final class XCDataModelIndexer: Indexer {
8+
enum XCDataModelError: Error {
9+
case failedToParse(path: FilePath, underlyingError: Error)
10+
}
811
private let files: Set<FilePath>
912
private let graph: SynchronizedSourceGraph
1013
private let logger: ContextualLogger
@@ -24,9 +27,13 @@ final class XCDataModelIndexer: Indexer {
2427
guard let self else { return }
2528

2629
let elapsed = try Benchmark.measure {
27-
try XCDataModelParser(path: path)
28-
.parse()
29-
.forEach { self.graph.add($0) }
30+
do {
31+
try XCDataModelParser(path: path)
32+
.parse()
33+
.forEach { self.graph.add($0) }
34+
} catch {
35+
throw XCDataModelError.failedToParse(path: path, underlyingError: error)
36+
}
3037
}
3138

3239
logger.debug("\(path.string) (\(elapsed)s)")

Sources/Indexer/XibIndexer.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import SourceGraph
55
import SystemPackage
66

77
final class XibIndexer: Indexer {
8+
enum XibError: Error {
9+
case failedToParse(path: FilePath, underlyingError: Error)
10+
}
811
private let xibFiles: Set<FilePath>
912
private let graph: SynchronizedSourceGraph
1013
private let logger: ContextualLogger
@@ -24,9 +27,13 @@ final class XibIndexer: Indexer {
2427
guard let self else { return }
2528

2629
let elapsed = try Benchmark.measure {
27-
try XibParser(path: xibPath)
28-
.parse()
29-
.forEach { self.graph.add($0) }
30+
do {
31+
try XibParser(path: xibPath)
32+
.parse()
33+
.forEach { self.graph.add($0) }
34+
} catch {
35+
throw XibError.failedToParse(path: xibPath, underlyingError: error)
36+
}
3037
}
3138

3239
logger.debug("\(xibPath.string) (\(elapsed)s)")

0 commit comments

Comments
 (0)