Skip to content

Commit ab207a2

Browse files
authored
Handle HTTP errors fetching image manifest (#1602)
1 parent b982a9b commit ab207a2

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/Control/Carrier/ContainerRegistryApi.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ getImageManifest src = context "Getting Image Manifest" $ do
190190
(digestOf manifestIndex platformArch)
191191

192192
parseOciManifest
193+
=<< fromResponse
193194
=<< mkRequest manager (registryCred src) (Just supportedManifestKinds)
194195
=<< (manifestEndpoint $ src{registryContainerRepositoryReference = manifestDigest})
195196
else do

src/Control/Carrier/ContainerRegistryApi/Errors.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ data ContainerRegistryApiErrorKind
3939
| Denied
4040
| Unsupported
4141
| OtherError
42+
| TooManyRequests
4243
deriving (Eq, Ord)
4344

4445
instance Show ContainerRegistryApiErrorKind where
@@ -49,6 +50,7 @@ instance Show ContainerRegistryApiErrorKind where
4950
show Unauthorized = "UNAUTHORIZED"
5051
show Denied = "DENIED"
5152
show Unsupported = "UNSUPPORTED"
53+
show TooManyRequests = "TOOMANYREQUESTS"
5254
show OtherError = "OTHER_UNKNOWN_ERROR"
5355

5456
instance FromJSON ContainerRegistryApiErrorKind where
@@ -61,6 +63,7 @@ errCodeToErrKind errorKind | show NameInvalid == errorKind = NameInvalid
6163
errCodeToErrKind errorKind | show NameUnknown == errorKind = NameUnknown
6264
errCodeToErrKind errorKind | show Unauthorized == errorKind = Unauthorized
6365
errCodeToErrKind errorKind | show Denied == errorKind = Denied
66+
errCodeToErrKind errorKind | show TooManyRequests == errorKind = TooManyRequests
6467
errCodeToErrKind errorKind | show Unsupported == errorKind = Unsupported
6568
errCodeToErrKind _ = OtherError
6669

@@ -103,7 +106,7 @@ instance ToDiagnostic UnknownApiError where
103106
let header =
104107
renderIt $
105108
vsep
106-
[ "Caught unexpected error from:" <> pretty ("(" <> show (statusCode status) <> ") " <> show uri)
109+
[ "Caught unexpected error from: " <> pretty ("(" <> show (statusCode status) <> ") " <> show uri)
107110
]
108111
Errata (Just header) [] Nothing
109112

0 commit comments

Comments
 (0)