Lowercase error messages (#945)

## Type of Change
- [x] Bug fix
- [ ] New feature  
- [ ] Breaking change
- [ ] Documentation update

## Motivation and Context
For consistency, all error messages are lowercased.

## Testing
- [ ] Tested locally
- [ ] Added/updated tests
- [ ] Added/updated docs

---------

Co-authored-by: J Logan <sgtbakerrahulnet@yahoo.com>
This commit is contained in:
Dmitry Kovba
2025-12-09 12:32:28 -08:00
committed by GitHub
co-authored by J Logan
parent 0733a81a6d
commit 38960553cb
21 changed files with 44 additions and 44 deletions
@@ -105,7 +105,7 @@ public actor BuildPipeline {
throw NSError(
domain: "untilFirstError",
code: 1,
userInfo: [NSLocalizedDescriptionKey: "Failed to initialize task continuation"])
userInfo: [NSLocalizedDescriptionKey: "failed to initialize task continuation"])
}
defer { taskContinuation.finish() }
let stream = AsyncStream<Error> { continuation in
+3 -3
View File
@@ -228,7 +228,7 @@ public final class BufferedCopyReader: AsyncSequence {
throw CocoaError(
.fileReadUnsupportedScheme,
userInfo: [
NSLocalizedDescriptionKey: "Reset not supported with InputStream-based implementation"
NSLocalizedDescriptionKey: "reset not supported with InputStream-based implementation"
])
}
@@ -240,7 +240,7 @@ public final class BufferedCopyReader: AsyncSequence {
throw CocoaError(
.fileReadUnsupportedScheme,
userInfo: [
NSLocalizedDescriptionKey: "Offset tracking not supported with InputStream-based implementation"
NSLocalizedDescriptionKey: "offset tracking not supported with InputStream-based implementation"
])
}
@@ -252,7 +252,7 @@ public final class BufferedCopyReader: AsyncSequence {
throw CocoaError(
.fileReadUnsupportedScheme,
userInfo: [
NSLocalizedDescriptionKey: "Seeking not supported with InputStream-based implementation"
NSLocalizedDescriptionKey: "seeking not supported with InputStream-based implementation"
])
}
@@ -31,7 +31,7 @@ public struct ClientDiskUsage {
guard let responseData = reply.dataNoCopy(key: .diskUsageStats) else {
throw ContainerizationError(
.internalError,
message: "Invalid response from server: missing disk usage data"
message: "invalid response from server: missing disk usage data"
)
}
@@ -84,7 +84,7 @@ extension ClientKernel {
throw err
}
throw ContainerizationError(
.notFound, message: "Default kernel not configured for architecture \(platform.architecture). Please use the `container system kernel set` command to configure it")
.notFound, message: "default kernel not configured for architecture \(platform.architecture), please use the `container system kernel set` command to configure it")
}
}
}
@@ -97,7 +97,7 @@ extension SystemPlatform {
case "amd64":
return .linuxAmd
default:
fatalError("Unknown architecture")
fatalError("unknown architecture")
}
}
}
@@ -41,7 +41,7 @@ public struct ClientVolume {
let reply = try await client.send(message)
guard let responseData = reply.dataNoCopy(key: .volume) else {
throw VolumeError.storageError("Invalid response from server")
throw VolumeError.storageError("invalid response from server")
}
return try JSONDecoder().decode(Volume.self, from: responseData)
+6 -6
View File
@@ -80,17 +80,17 @@ public enum VolumeError: Error, LocalizedError {
public var errorDescription: String? {
switch self {
case .volumeNotFound(let name):
return "Volume '\(name)' not found"
return "volume '\(name)' not found"
case .volumeAlreadyExists(let name):
return "Volume '\(name)' already exists"
return "volume '\(name)' already exists"
case .volumeInUse(let name):
return "Volume '\(name)' is currently in use and cannot be accessed by another container, or deleted."
return "volume '\(name)' is currently in use and cannot be accessed by another container, or deleted"
case .invalidVolumeName(let name):
return "Invalid volume name '\(name)'"
return "invalid volume name '\(name)'"
case .driverNotSupported(let driver):
return "Volume driver '\(driver)' is not supported"
return "volume driver '\(driver)' is not supported"
case .storageError(let message):
return "Storage error: \(message)"
return "storage error: \(message)"
}
}
}
+1 -1
View File
@@ -262,7 +262,7 @@ public struct Parser {
}()
guard let commandToRun = processArguments, commandToRun.count > 0 else {
throw ContainerizationError(.invalidArgument, message: "Command/Entrypoint not specified for container process")
throw ContainerizationError(.invalidArgument, message: "command/entrypoint not specified for container process")
}
let defaultUser: ProcessConfiguration.User = {
@@ -74,7 +74,7 @@ extension Application {
guard let container = allContainers.first(where: { $0.id == containerId || $0.id.starts(with: containerId) }) else {
throw ContainerizationError(
.notFound,
message: "Error: No such container: \(containerId)"
message: "no such container: \(containerId)"
)
}
found.append(container)
@@ -102,7 +102,7 @@ extension Application {
guard allContainers.first(where: { $0.id == containerId || $0.id.starts(with: containerId) }) != nil else {
throw ContainerizationError(
.notFound,
message: "Error: No such container: \(containerId)"
message: "no such container: \(containerId)"
)
}
}
@@ -140,7 +140,7 @@ extension Application {
}
} catch {
clearScreen()
print("Error collecting stats: \(error)")
print("error collecting stats: \(error)")
try await Task.sleep(for: .seconds(2))
}
}
@@ -42,9 +42,9 @@ struct DefaultCommand: AsyncParsableCommand {
// Check for edge cases and unknown options to match the behavior in the absence of plugins.
if command.isEmpty {
throw ValidationError("Unknown argument '\(command)'")
throw ValidationError("unknown argument '\(command)'")
} else if command.starts(with: "-") {
throw ValidationError("Unknown option '\(command)'")
throw ValidationError("unknown option '\(command)'")
}
// Compute canonical plugin directories to show in helpful errors (avoid hard-coded paths)
@@ -67,7 +67,7 @@ extension Application {
private func setKernelFromBinary() async throws {
guard let binaryPath else {
throw ArgumentParser.ValidationError("Missing argument '--binary'")
throw ArgumentParser.ValidationError("missing argument '--binary'")
}
let absolutePath = URL(fileURLWithPath: binaryPath, relativeTo: .currentDirectory()).absoluteURL.absoluteString
let platform = try getSystemPlatform()
@@ -76,10 +76,10 @@ extension Application {
private func setKernelFromTar() async throws {
guard let binaryPath else {
throw ArgumentParser.ValidationError("Missing argument '--binary'")
throw ArgumentParser.ValidationError("missing argument '--binary'")
}
guard let tarPath else {
throw ArgumentParser.ValidationError("Missing argument '--tar")
throw ArgumentParser.ValidationError("missing argument '--tar")
}
let platform = try getSystemPlatform()
let localTarPath = URL(fileURLWithPath: tarPath, relativeTo: .currentDirectory()).path
@@ -44,7 +44,7 @@ extension Application {
guard let jsonString = String(data: data, encoding: .utf8) else {
throw ContainerizationError(
.internalError,
message: "Failed to encode JSON output"
message: "failed to encode JSON output"
)
}
print(jsonString)
@@ -84,7 +84,7 @@ public enum DefaultsStore {
private static var udSuite: UserDefaults {
guard let ud = UserDefaults.init(suiteName: self.userDefaultDomain) else {
fatalError("Failed to initialize UserDefaults for domain \(self.userDefaultDomain)")
fatalError("failed to initialize UserDefaults for domain \(self.userDefaultDomain)")
}
return ud
}
+4 -4
View File
@@ -133,7 +133,7 @@ extension PluginLoader {
}.first)
else {
log?.warning(
"Not installing plugin with missing configuration",
"not installing plugin with missing configuration",
metadata: [
"path": "\(installURL.path)"
]
@@ -144,7 +144,7 @@ extension PluginLoader {
// Warn and skip if this plugin name has been encountered already
guard !pluginNames.contains(plugin.name) else {
log?.warning(
"Not installing shadowed plugin",
"not installing shadowed plugin",
metadata: [
"path": "\(installURL.path)",
"name": "\(plugin.name)",
@@ -157,7 +157,7 @@ extension PluginLoader {
pluginNames.insert(plugin.name)
} catch {
log?.warning(
"Not installing plugin with invalid configuration",
"not installing plugin with invalid configuration",
metadata: [
"path": "\(installURL.path)",
"error": "\(error)",
@@ -183,7 +183,7 @@ extension PluginLoader {
}
} catch {
log?.warning(
"Not installing plugin with invalid configuration",
"not installing plugin with invalid configuration",
metadata: [
"name": "\(name)",
"error": "\(error)",
+2 -2
View File
@@ -72,12 +72,12 @@ public struct ServiceManager {
let status = launchctl.terminationStatus
guard status == 0 else {
throw ContainerizationError(
.internalError, message: "command `launchctl list` failed with status \(status). Message: \(String(data: stderrData, encoding: .utf8) ?? "No error message")")
.internalError, message: "command `launchctl list` failed with status \(status), message: \(String(data: stderrData, encoding: .utf8) ?? "no error message")")
}
guard let outputText = String(data: outputData, encoding: .utf8) else {
throw ContainerizationError(
.internalError, message: "could not decode output of command `launchctl list`. Message: \(String(data: stderrData, encoding: .utf8) ?? "No error message")")
.internalError, message: "could not decode output of command `launchctl list`, message: \(String(data: stderrData, encoding: .utf8) ?? "no error message")")
}
// The third field of each line of launchctl list output is the label
@@ -26,7 +26,7 @@ extension CommandLine {
/// Create the buffer and get the path
buffer = [CChar](repeating: 0, count: Int(bufferSize))
guard _NSGetExecutablePath(&buffer, &bufferSize) == 0 else {
fatalError("UNEXPECTED: failed to get executable path")
fatalError("unexpected: failed to get executable path")
}
/// Return the path with the executable file component removed the last component and
+3 -3
View File
@@ -239,12 +239,12 @@ extension xpc_object_t {
}
var connectionError: Bool {
precondition(isError, "Not an error")
precondition(isError, "not an error")
return xpc_equal(self, XPC_ERROR_CONNECTION_INVALID) || xpc_equal(self, XPC_ERROR_CONNECTION_INTERRUPTED)
}
var connectionClosed: Bool {
precondition(isError, "Not an error")
precondition(isError, "not an error")
return xpc_equal(self, XPC_ERROR_CONNECTION_INVALID)
}
@@ -253,7 +253,7 @@ extension xpc_object_t {
}
var errorDescription: String? {
precondition(isError, "Not an error")
precondition(isError, "not an error")
let cstring = xpc_dictionary_get_string(self, XPC_ERROR_KEY_DESCRIPTION)
guard let cstring else {
return nil
@@ -97,12 +97,12 @@ struct ContainerDNSHandler: DNSHandler {
let components = ipAllocation.address.split(separator: "/")
guard !components.isEmpty else {
throw DNSResolverError.serverError("Invalid IP format: empty address")
throw DNSResolverError.serverError("invalid IP format: empty address")
}
let ipString = String(components[0])
guard let ip = IPv4(ipString) else {
throw DNSResolverError.serverError("Failed to parse IP address: \(ipString)")
throw DNSResolverError.serverError("failed to parse IP address: \(ipString)")
}
return HostRecord<IPv4>(name: question.name, ttl: ttl, ip: ip)
@@ -153,7 +153,7 @@ public actor VolumesService {
let sizeInBytes = UInt64(bytes)
guard sizeInBytes >= minSize else {
throw VolumeError.storageError("Volume size too small: minimum 1MiB")
throw VolumeError.storageError("volume size too small: minimum 1MiB")
}
return sizeInBytes
@@ -206,7 +206,7 @@ public actor VolumesService {
labels: [String: String]
) async throws -> Volume {
guard VolumeStorage.isValidVolumeName(name) else {
throw VolumeError.invalidVolumeName("Invalid volume name '\(name)': must match \(VolumeStorage.volumeNamePattern)")
throw VolumeError.invalidVolumeName("invalid volume name '\(name)': must match \(VolumeStorage.volumeNamePattern)")
}
// Check if volume already exists by trying to list and finding it
@@ -245,7 +245,7 @@ public actor VolumesService {
private func _delete(name: String) async throws {
guard VolumeStorage.isValidVolumeName(name) else {
throw VolumeError.invalidVolumeName("Invalid volume name '\(name)': must match \(VolumeStorage.volumeNamePattern)")
throw VolumeError.invalidVolumeName("invalid volume name '\(name)': must match \(VolumeStorage.volumeNamePattern)")
}
// Check if volume exists by trying to list and finding it
@@ -273,7 +273,7 @@ public actor VolumesService {
private func _inspect(_ name: String) async throws -> Volume {
guard VolumeStorage.isValidVolumeName(name) else {
throw VolumeError.invalidVolumeName("Invalid volume name '\(name)': must match \(VolumeStorage.volumeNamePattern)")
throw VolumeError.invalidVolumeName("invalid volume name '\(name)': must match \(VolumeStorage.volumeNamePattern)")
}
let volumes = try await store.list()
@@ -235,7 +235,7 @@ extension ImagesService {
throw err
}
guard authentication != nil else {
throw ContainerizationError(.internalError, message: "\(String(describing: err)). No credentials found for host \(host)")
throw ContainerizationError(.internalError, message: "\(String(describing: err)), no credentials found for host \(host)")
}
throw err
}
@@ -84,7 +84,7 @@ public actor SnapshotStore {
throw ContainerizationError(.internalError, message: "missing platform for descriptor \(desc.digest)")
}
guard let unpacker = try await self.unpackStrategy(image, platform) else {
self.log?.warning("Skipping unpack for \(image.reference) for platform \(platform.description). No unpacker configured.")
self.log?.warning("no unpacker configured, skipping unpack for \(image.reference) for platform \(platform.description)")
continue
}
let currentSubTask = await taskManager.startTask()
@@ -163,7 +163,7 @@ extension ProgressConfig {
public var description: String {
switch self {
case .invalid(let reason):
return "Failed to validate config (\(reason))"
return "failed to validate config (\(reason))"
}
}
}