Skip to content

Commit d7e0ae6

Browse files
authored
Merge pull request swiftlang#230 from dabelknap/pound-error
Use a workaround to catch unknownTokenKind("pound_error") errors.
2 parents 72d8ba7 + 512d74c commit d7e0ae6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Sources/swift-format/Run.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ func lintMain(configuration: Configuration, path: String) -> Int {
3737
return 1
3838
}
3939
catch {
40+
// Workaround: we're unable to directly catch unknownTokenKind errors due to access
41+
// restrictions. TODO: this can be removed when we update to Swift 5.0.
42+
if "\(error)" == "unknownTokenKind(\"pound_error\")" {
43+
stderrStream.write("Unable to lint \(path): unknownTokenKind(\"pound_error\")\n")
44+
stderrStream.flush()
45+
return 1
46+
}
4047
stderrStream.write("Unable to lint \(path): \(error)\n")
4148
stderrStream.flush()
4249
exit(1)
@@ -81,6 +88,13 @@ func formatMain(
8188
return 1
8289
}
8390
catch {
91+
// Workaround: we're unable to directly catch unknownTokenKind errors due to access
92+
// restrictions. TODO: this can be removed when we update to Swift 5.0.
93+
if "\(error)" == "unknownTokenKind(\"pound_error\")" {
94+
stderrStream.write("Unable to format \(path): unknownTokenKind(\"pound_error\")\n")
95+
stderrStream.flush()
96+
return 1
97+
}
8498
stderrStream.write("Unable to format \(path): \(error)\n")
8599
stderrStream.flush()
86100
exit(1)

0 commit comments

Comments
 (0)