Skip to content

Commit 94dfb2d

Browse files
authored
Merge pull request #1090 from compnerd/fatality
Driver: use a proper error rather than `fatalError`
2 parents ecdc811 + 94eafe4 commit 94dfb2d

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import struct TSCUtility.Version
1919
/// The Swift driver.
2020
public struct Driver {
2121
public enum Error: Swift.Error, Equatable, DiagnosticData {
22+
case unknownOrMissingSubcommand(String)
2223
case invalidDriverName(String)
2324
case invalidInput(String)
2425
case noInputFiles
@@ -49,6 +50,8 @@ public struct Driver {
4950

5051
public var description: String {
5152
switch self {
53+
case .unknownOrMissingSubcommand(let subcommand):
54+
return "unknown or missing subcommand '\(subcommand)'"
5255
case .invalidDriverName(let driverName):
5356
return "invalid driver name: \(driverName)"
5457
case .invalidInput(let input):

Sources/swift-driver/main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ do {
6767
?? Process.findExecutable(subcommand)
6868

6969
if subcommandPath == nil || !localFileSystem.exists(subcommandPath!) {
70-
fatalError("cannot find subcommand executable '\(subcommand)'")
70+
throw Driver.Error.unknownOrMissingSubcommand(subcommand)
7171
}
7272

7373
// Execute the subcommand.

0 commit comments

Comments
 (0)