Skip to content

Commit bb0cd39

Browse files
authored
Lowercase error messages (#440)
For consistency, all error messages are lowercased.
1 parent d473f89 commit bb0cd39

27 files changed

+124
-124
lines changed

Sources/Containerization/Image/Image.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public struct Image: Sendable {
5959
/// Returns the underlying OCI index for the image.
6060
public func index() async throws -> Index {
6161
guard let content: Content = try await contentStore.get(digest: digest) else {
62-
throw ContainerizationError(.notFound, message: "Content with digest \(digest)")
62+
throw ContainerizationError(.notFound, message: "content with digest \(digest)")
6363
}
6464
return try content.decode()
6565
}
@@ -71,10 +71,10 @@ public struct Image: Sendable {
7171
desc.platform == platform
7272
}
7373
guard let desc else {
74-
throw ContainerizationError(.unsupported, message: "Platform \(platform.description)")
74+
throw ContainerizationError(.unsupported, message: "platform \(platform.description)")
7575
}
7676
guard let content: Content = try await contentStore.get(digest: desc.digest) else {
77-
throw ContainerizationError(.notFound, message: "Content with digest \(digest)")
77+
throw ContainerizationError(.notFound, message: "content with digest \(digest)")
7878
}
7979
return try content.decode()
8080
}
@@ -95,7 +95,7 @@ public struct Image: Sendable {
9595
let manifest = try await self.manifest(for: platform)
9696
let desc = manifest.config
9797
guard let content: Content = try await contentStore.get(digest: desc.digest) else {
98-
throw ContainerizationError(.notFound, message: "Content with digest \(digest)")
98+
throw ContainerizationError(.notFound, message: "content with digest \(digest)")
9999
}
100100
return try content.decode()
101101
}
@@ -120,10 +120,10 @@ public struct Image: Sendable {
120120
/// Returns a reference to the content blob for the image. The specified digest must be referenced by the image in one of its layers.
121121
public func getContent(digest: String) async throws -> Content {
122122
guard try await self.referencedDigests().contains(digest.trimmingDigestPrefix) else {
123-
throw ContainerizationError(.internalError, message: "Image \(self.reference) does not reference digest \(digest)")
123+
throw ContainerizationError(.internalError, message: "image \(self.reference) does not reference digest \(digest)")
124124
}
125125
guard let content: Content = try await contentStore.get(digest: digest) else {
126-
throw ContainerizationError(.notFound, message: "Content with digest \(digest)")
126+
throw ContainerizationError(.notFound, message: "content with digest \(digest)")
127127
}
128128
return content
129129
}

Sources/Containerization/Image/ImageStore/ImageStore+Export.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ extension ImageStore {
6363
for chunk in layerGroup.chunks(ofCount: 8) {
6464
for desc in chunk {
6565
guard let content = try await self.contentStore.get(digest: desc.digest) else {
66-
throw ContainerizationError(.notFound, message: "Content with digest \(desc.digest)")
66+
throw ContainerizationError(.notFound, message: "content with digest \(desc.digest)")
6767
}
6868
group.addTask {
6969
let readStream = try ReadStream(url: content.path)
@@ -104,7 +104,7 @@ extension ImageStore {
104104

105105
private func createIndex(from index: Descriptor, matching: (Platform) -> Bool) async throws -> Data {
106106
guard let content = try await self.contentStore.get(digest: index.digest) else {
107-
throw ContainerizationError(.notFound, message: "Content with digest \(index.digest)")
107+
throw ContainerizationError(.notFound, message: "content with digest \(index.digest)")
108108
}
109109
var idx: Index = try content.decode()
110110
let manifests = idx.manifests
@@ -156,7 +156,7 @@ extension ImageStore {
156156
for desc in descs {
157157
let mediaType = desc.mediaType
158158
guard let content = try await self.contentStore.get(digest: desc.digest) else {
159-
throw ContainerizationError(.notFound, message: "Content with digest \(desc.digest)")
159+
throw ContainerizationError(.notFound, message: "content with digest \(desc.digest)")
160160
}
161161
switch mediaType {
162162
case MediaTypes.index, MediaTypes.dockerManifestList:

Sources/Containerization/Image/ImageStore/ImageStore+Import.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ extension ImageStore {
7575
// the Index.
7676
let supportedPlatforms = index.manifests.compactMap { $0.platform }
7777
guard supportedPlatforms.allSatisfy(matcher) else {
78-
throw ContainerizationError(.unsupported, message: "Image \(root.digest) does not support required platforms")
78+
throw ContainerizationError(.unsupported, message: "image \(root.digest) does not support required platforms")
7979
}
8080
let writer = try ContentWriter(for: self.ingestDir)
8181
let result = try writer.create(from: index)
@@ -95,7 +95,7 @@ extension ImageStore {
9595
}
9696
return try await self.client.fetch(name: name, descriptor: descriptor)
9797
} catch {
98-
throw ContainerizationError(.internalError, message: "Cannot fetch content with digest \(descriptor.digest)", cause: error)
98+
throw ContainerizationError(.internalError, message: "cannot fetch content with digest \(descriptor.digest)", cause: error)
9999
}
100100
}
101101

@@ -170,7 +170,7 @@ extension ImageStore {
170170
let tempFile = ingestDir.appendingPathComponent(id)
171171
let (_, digest) = try await client.fetchBlob(name: name, descriptor: descriptor, into: tempFile, progress: progress)
172172
guard digest.digestString == descriptor.digest else {
173-
throw ContainerizationError(.internalError, message: "Digest mismatch expected \(descriptor.digest), got \(digest.digestString)")
173+
throw ContainerizationError(.internalError, message: "digest mismatch expected \(descriptor.digest), got \(digest.digestString)")
174174
}
175175
do {
176176
try fm.moveItem(at: tempFile, to: ingestDir.appendingPathComponent(digest.encoded))
@@ -194,7 +194,7 @@ extension ImageStore {
194194
])
195195
}
196196
guard result.digest.digestString == descriptor.digest else {
197-
throw ContainerizationError(.internalError, message: "Digest mismatch expected \(descriptor.digest), got \(result.digest.digestString)")
197+
throw ContainerizationError(.internalError, message: "digest mismatch expected \(descriptor.digest), got \(result.digest.digestString)")
198198
}
199199
return data
200200
}
@@ -209,7 +209,7 @@ extension ImageStore {
209209
throw ContainerizationError(
210210
.internalError,
211211
message:
212-
"Descriptor \(root.mediaType) with digest \(root.digest) does not list any supported platform or supports more than one platform. Supported platforms = \(supportedPlatforms)"
212+
"descriptor \(root.mediaType) with digest \(root.digest) does not list any supported platform or supports more than one platform. Supported platforms = \(supportedPlatforms)"
213213
)
214214
}
215215
let platform = supportedPlatforms.first!
@@ -223,7 +223,7 @@ extension ImageStore {
223223
])
224224
return index
225225
default:
226-
throw ContainerizationError(.internalError, message: "Failed to create index for descriptor \(root.digest), media type \(root.mediaType)")
226+
throw ContainerizationError(.internalError, message: "failed to create index for descriptor \(root.digest), media type \(root.mediaType)")
227227
}
228228
}
229229

Sources/Containerization/Image/ImageStore/ImageStore+OCILayout.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extension ImageStore {
4343
let image = try await self.get(reference: reference)
4444
let allowedMediaTypes = [MediaTypes.dockerManifestList, MediaTypes.index]
4545
guard allowedMediaTypes.contains(image.mediaType) else {
46-
throw ContainerizationError(.internalError, message: "Cannot save image \(image.reference) with Index media type \(image.mediaType)")
46+
throw ContainerizationError(.internalError, message: "cannot save image \(image.reference) with Index media type \(image.mediaType)")
4747
}
4848
toSave.append(image)
4949
}
@@ -54,7 +54,7 @@ extension ImageStore {
5454
let ref = try Reference.parse(image.reference)
5555
let name = ref.path
5656
guard let tag = ref.tag ?? ref.digest else {
57-
throw ContainerizationError(.invalidArgument, message: "Invalid tag/digest for image reference \(image.reference)")
57+
throw ContainerizationError(.invalidArgument, message: "invalid tag/digest for image reference \(image.reference)")
5858
}
5959
let operation = ExportOperation(name: name, tag: tag, contentStore: self.contentStore, client: client, progress: nil)
6060
var descriptor = try await operation.export(index: image.descriptor, platforms: matcher)
@@ -99,7 +99,7 @@ extension ImageStore {
9999
return images
100100
}
101101
guard importedImages.count > 0 else {
102-
throw ContainerizationError(.internalError, message: "Failed to import image")
102+
throw ContainerizationError(.internalError, message: "failed to import image")
103103
}
104104
return importedImages
105105
} catch {

Sources/Containerization/Image/ImageStore/ImageStore+ReferenceManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extension ImageStore {
4343
let data = try Data(contentsOf: statePath)
4444
return try JSONDecoder().decode(State.self, from: data)
4545
} catch {
46-
throw ContainerizationError(.internalError, message: "Failed to load image state \(error.localizedDescription)")
46+
throw ContainerizationError(.internalError, message: "failed to load image state \(error.localizedDescription)")
4747
}
4848
}
4949

Sources/Containerization/Image/ImageStore/ImageStore.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ extension ImageStore {
208208
do {
209209
_ = try Reference.parse(new)
210210
} catch {
211-
throw ContainerizationError(.invalidArgument, message: "Invalid reference \(new). Error: \(error)")
211+
throw ContainerizationError(.invalidArgument, message: "invalid reference \(new). Error: \(error)")
212212
}
213213
let newDescription = Image.Description(reference: new, descriptor: descriptor)
214214
return try await self.create(description: newDescription)
@@ -242,7 +242,7 @@ extension ImageStore {
242242
let ref = try Reference.parse(reference)
243243
let name = ref.path
244244
guard let tag = ref.tag ?? ref.digest else {
245-
throw ContainerizationError(.invalidArgument, message: "Invalid tag/digest for image reference \(reference)")
245+
throw ContainerizationError(.invalidArgument, message: "invalid tag/digest for image reference \(reference)")
246246
}
247247

248248
let rootDescriptor = try await client.resolve(name: name, tag: tag)
@@ -282,12 +282,12 @@ extension ImageStore {
282282
let img = try await self.get(reference: reference)
283283
let allowedMediaTypes = [MediaTypes.dockerManifestList, MediaTypes.index]
284284
guard allowedMediaTypes.contains(img.mediaType) else {
285-
throw ContainerizationError(.internalError, message: "Cannot push image \(reference) with Index media type \(img.mediaType)")
285+
throw ContainerizationError(.internalError, message: "cannot push image \(reference) with Index media type \(img.mediaType)")
286286
}
287287
let ref = try Reference.parse(reference)
288288
let name = ref.path
289289
guard let tag = ref.tag ?? ref.digest else {
290-
throw ContainerizationError(.invalidArgument, message: "Invalid tag/digest for image reference \(reference)")
290+
throw ContainerizationError(.invalidArgument, message: "invalid tag/digest for image reference \(reference)")
291291
}
292292
let client = try RegistryClient(reference: reference, insecure: insecure, auth: auth)
293293
let operation = ExportOperation(name: name, tag: tag, contentStore: self.contentStore, client: client, progress: progress)

Sources/Containerization/Image/Unpacker/EXT4Unpacker.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public struct EXT4Unpacker: Unpacker {
7272
progress: ProgressHandler? = nil
7373
) async throws -> Mount {
7474
#if !os(macOS)
75-
throw ContainerizationError(.unsupported, message: "Cannot unpack an image on current platform")
75+
throw ContainerizationError(.unsupported, message: "cannot unpack an image on current platform")
7676
#else
7777
let cleanedPath = try prepareUnpackPath(path: path)
7878
let manifest = try await image.manifest(for: platform)
@@ -95,7 +95,7 @@ public struct EXT4Unpacker: Unpacker {
9595
case MediaTypes.imageLayerGzip, MediaTypes.dockerImageLayerGzip:
9696
compression = .gzip
9797
default:
98-
throw ContainerizationError(.unsupported, message: "Media type \(layer.mediaType) not supported.")
98+
throw ContainerizationError(.unsupported, message: "media type \(layer.mediaType) not supported.")
9999
}
100100
try filesystem.unpack(
101101
source: content.path,

Sources/Containerization/LinuxProcess.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ extension LinuxProcess {
391391
}
392392
}
393393
} catch {
394-
self.logger?.error("Timeout waiting for IO to complete for process \(id): \(error)")
394+
self.logger?.error("timeout waiting for IO to complete for process \(id): \(error)")
395395
}
396396
self.state.withLock {
397397
$0.ioTracker = nil

Sources/ContainerizationArchive/ArchiveError.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,39 +41,39 @@ public enum ArchiveError: Error, CustomStringConvertible {
4141
public var description: String {
4242
switch self {
4343
case .unableToCreateArchive:
44-
return "Unable to create an archive."
44+
return "unable to create an archive."
4545
case .noUnderlyingArchive:
46-
return "No underlying archive was provided."
46+
return "no underlying archive was provided."
4747
case .noArchiveInCallback:
48-
return "No archive was provided in the callback."
48+
return "no archive was provided in the callback."
4949
case .noDelegateConfigured:
50-
return "No delegate was configured."
50+
return "no delegate was configured."
5151
case .delegateFreedBeforeCallback:
52-
return "The delegate was freed before the callback was invoked."
52+
return "the delegate was freed before the callback was invoked."
5353
case .unableToSetFormat(let code, let name):
54-
return "Unable to set the archive format \(name), code \(code)"
54+
return "unable to set the archive format \(name), code \(code)"
5555
case .unableToAddFilter(let code, let name):
56-
return "Unable to set the archive filter \(name), code \(code)"
56+
return "unable to set the archive filter \(name), code \(code)"
5757
case .unableToWriteEntryHeader(let code):
58-
return "Unable to write the entry header to the archive. Error code \(code)"
58+
return "unable to write the entry header to the archive. Error code \(code)"
5959
case .unableToWriteData(let code):
60-
return "Unable to write data to the archive. Error code \(code)"
60+
return "unable to write data to the archive. Error code \(code)"
6161
case .unableToCloseArchive(let code):
62-
return "Unable to close the archive. Error code \(code)"
62+
return "unable to close the archive. Error code \(code)"
6363
case .unableToOpenArchive(let code):
64-
return "Unable to open the archive. Error code \(code)"
64+
return "unable to open the archive. Error code \(code)"
6565
case .unableToSetOption(_):
66-
return "Unable to set an option on the archive."
66+
return "unable to set an option on the archive."
6767
case .failedToSetLocale(let locales):
68-
return "Failed to set locale to \(locales)"
68+
return "failed to set locale to \(locales)"
6969
case .failedToGetProperty(let path, let propertyName):
70-
return "Failed to read property \(propertyName) from file at path \(path)"
70+
return "failed to read property \(propertyName) from file at path \(path)"
7171
case .failedToDetectFilter:
72-
return "Failed to detect filter from archive."
72+
return "failed to detect filter from archive."
7373
case .failedToDetectFormat:
74-
return "Failed to detect format from archive."
74+
return "failed to detect format from archive."
7575
case .failedToExtractArchive(let reason):
76-
return "Failed to extract archive: \(reason)"
76+
return "failed to extract archive: \(reason)"
7777
}
7878
}
7979
}

Sources/ContainerizationArchive/Reader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ extension ArchiveReader {
204204
}
205205
}
206206
guard foundEntry else {
207-
throw ArchiveError.failedToExtractArchive("No entries found in archive")
207+
throw ArchiveError.failedToExtractArchive("no entries found in archive")
208208
}
209209
}
210210

0 commit comments

Comments
 (0)