Skip to content

Commit 7256843

Browse files
surayya-MSbaronfel
authored andcommitted
fix catching UnableToDownloadFromRepositoryException in PushToLocalRegistryAsync
1 parent f75e4c3 commit 7256843

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/Containers/Microsoft.NET.Build.Containers/ContainerBuilder.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ private static async Task<int> PushToLocalRegistryAsync(ILogger logger, BuiltIma
215215
await containerRegistry.LoadAsync(builtImage, sourceImageReference, destinationImageReference, cancellationToken).ConfigureAwait(false);
216216
logger.LogInformation(Strings.ContainerBuilder_ImageUploadedToLocalDaemon, destinationImageReference, containerRegistry);
217217
}
218+
catch (UnableToDownloadFromRepositoryException)
219+
{
220+
logger.LogError(Resource.FormatString(nameof(Strings.UnableToDownloadFromRepository)), sourceImageReference);
221+
return 1;
222+
}
218223
catch (Exception ex)
219224
{
220225
logger.LogError(Resource.FormatString(nameof(Strings.RegistryOutputPushFailed), ex.Message));
@@ -237,11 +242,6 @@ private static async Task<int> PushToRemoteRegistryAsync(ILogger logger, BuiltIm
237242
cancellationToken)).ConfigureAwait(false);
238243
logger.LogInformation(Strings.ContainerBuilder_ImageUploadedToRegistry, destinationImageReference, destinationImageReference.RemoteRegistry.RegistryName);
239244
}
240-
catch (UnableToDownloadFromRepositoryException)
241-
{
242-
logger.LogError(Resource.FormatString(nameof(Strings.UnableToDownloadFromRepository)), sourceImageReference);
243-
return 1;
244-
}
245245
catch (UnableToAccessRepositoryException)
246246
{
247247
logger.LogError(Resource.FormatString(nameof(Strings.UnableToAccessRepository), destinationImageReference.Repository, destinationImageReference.RemoteRegistry!.RegistryName));

src/Containers/Microsoft.NET.Build.Containers/ImagePublisher.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ private static async Task PushToLocalRegistryAsync<T>(
107107
await loadFunc(image, sourceImageReference, destinationImageReference, cancellationToken).ConfigureAwait(false);
108108
Log.LogMessage(MessageImportance.High, Strings.ContainerBuilder_ImageUploadedToLocalDaemon, destinationImageReference, localRegistry);
109109
}
110+
catch (UnableToDownloadFromRepositoryException)
111+
{
112+
Log.LogErrorWithCodeFromResources(nameof(Strings.UnableToDownloadFromRepository), sourceImageReference);
113+
}
110114
catch (ContainerHttpException e)
111115
{
112116
Log.LogErrorFromException(e, true);
@@ -145,10 +149,6 @@ await pushFunc(
145149
cancellationToken).ConfigureAwait(false);
146150
Log.LogMessage(MessageImportance.High, successMessage, destinationImageReference, destinationImageReference.RemoteRegistry!.RegistryName);
147151
}
148-
catch (UnableToAccessRepositoryException)
149-
{
150-
Log.LogErrorWithCodeFromResources(nameof(Strings.UnableToAccessRepository), destinationImageReference.Repository, destinationImageReference.RemoteRegistry!.RegistryName);
151-
}
152152
catch (ContainerHttpException e)
153153
{
154154
Log.LogErrorFromException(e, true);

0 commit comments

Comments
 (0)