Skip to content

Commit 9560efa

Browse files
authored
Merge pull request swiftlang#218 from dabelknap/errormessage
Improve error message when formatting fails
2 parents 0e6f628 + 8dcea78 commit 9560efa

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/swift-format/Run.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ func lintMain(configuration: Configuration, path: String) -> Int {
3131
do {
3232
try linter.lint(contentsOf: url)
3333
} catch {
34-
fatalError("\(error)")
34+
stderrStream.write("Unable to lint \(path): \(error)\n")
35+
stderrStream.flush()
36+
exit(1)
3537
}
3638
return diagnosticEngine.diagnostics.isEmpty ? 0 : 1
3739
}
@@ -67,7 +69,9 @@ func formatMain(
6769
stdoutStream.flush()
6870
}
6971
} catch {
70-
fatalError("\(error)")
72+
stderrStream.write("Unable to format \(path): \(error)\n")
73+
stderrStream.flush()
74+
exit(1)
7175
}
7276
return 0
7377
}

0 commit comments

Comments
 (0)