Skip to content

Commit

Permalink
ContainerRegistry: Fix decodingErrors parameters which were still usi…
Browse files Browse the repository at this point in the history
…ng raw error codes (#22)

### Motivation

`swift-http-types` provides enums giving readable names for HTTP error codes.   We should use these enums everewhere.

### Modifications

Fix a few places where raw HTTP error codes were still being used.

### Result

The code is more consistent.   No functional change.

### Test Plan

Tests continue to pass.
  • Loading branch information
euanh authored Oct 14, 2024
1 parent bca5f51 commit 692cb27
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Sources/ContainerRegistry/Blobs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public extension RegistryClient {
do {
let _ = try await executeRequestThrowing(
.head(registryURLForPath("/v2/\(repository)/blobs/\(digest)")),
decodingErrors: [404]
decodingErrors: [.notFound]
)
return true
} catch HTTPClientError.unexpectedStatusCode(status: .notFound, _, _) { return false }
Expand All @@ -83,7 +83,7 @@ public extension RegistryClient {

return try await executeRequestThrowing(
.get(registryURLForPath("/v2/\(repository)/blobs/\(digest)"), accepting: ["application/octet-stream"]),
decodingErrors: [404]
decodingErrors: [.notFound]
)
.data
}
Expand All @@ -106,7 +106,7 @@ public extension RegistryClient {

return try await executeRequestThrowing(
.get(registryURLForPath("/v2/\(repository)/blobs/\(digest)"), accepting: ["application/octet-stream"]),
decodingErrors: [404]
decodingErrors: [.notFound]
)
.data
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/ContainerRegistry/Tags.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public extension RegistryClient {
precondition(repository.count > 0, "repository must not be an empty string")
return try await executeRequestThrowing(
.get(registryURLForPath("/v2/\(repository)/tags/list")),
decodingErrors: [404]
decodingErrors: [.notFound]
)
.data
}
Expand Down

0 comments on commit 692cb27

Please sign in to comment.