Skip to content

Commit 5c067e0

Browse files
committed
containertool: Print human-readable error messages for repository validation errors
1 parent ed2d895 commit 5c067e0

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Sources/containertool/Extensions/Errors+CustomStringConvertible.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,17 @@ extension ContainerRegistry.DistributionErrors: Swift.CustomStringConvertible {
4646
/// A human-readable string describing a collection of unhandled distribution protocol errors
4747
public var description: String { errors.map { $0.description }.joined(separator: "\n") }
4848
}
49+
50+
extension ContainerRegistry.ImageReference.Repository.ValidationError: Swift.CustomStringConvertible {
51+
/// A human-readable string describing an image reference validation error
52+
public var description: String {
53+
switch self {
54+
case .emptyString:
55+
return "Invalid reference format: repository name cannot be empty"
56+
case .containsUppercaseLetters(let rawValue):
57+
return "Invalid reference format: repository name (\(rawValue)) must be lowercase"
58+
case .invalidReferenceFormat(let rawValue):
59+
return "Invalid reference format: repository name (\(rawValue)) contains invalid characters"
60+
}
61+
}
62+
}

0 commit comments

Comments
 (0)