Skip to content

Commit

Permalink
WhiskyCmd: Correctly use stderr and non-0 exit code on error
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Mar 6, 2024
1 parent 512b759 commit 5c6ecca
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions WhiskyCmd/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ extension Whisky {
bottlesList.paths.append(bottleURL)
print("Created new bottle \"\(name)\".")
} catch {
print(error)
throw ValidationError("\(error)")
}
}
}
Expand Down Expand Up @@ -132,7 +132,7 @@ extension Whisky {
print(error)
}
} else {
print("No bottle called \"\(name)\" found.")
throw ValidationError("No bottle called \"\(name)\" found.")
}
}
}
Expand All @@ -152,7 +152,7 @@ extension Whisky {
bottlesList.paths.removeAll(where: { $0 == bottleToRemove.url })
print("Removed \"\(name)\".")
} else {
print("No bottle called \"\(name)\" found.")
throw ValidationError("No bottle called \"\(name)\" found.")
}
}
}
Expand All @@ -169,8 +169,7 @@ extension Whisky {
let bottles = bottlesList.loadBottles()

guard let bottle = bottles.first(where: { $0.settings.name == bottleName }) else {
print("A bottle with that name doesn't exist.")
return
throw ValidationError("A bottle with that name doesn't exist.")
}

let url = URL(fileURLWithPath: path)
Expand Down

0 comments on commit 5c6ecca

Please sign in to comment.