From 0cbb73c0249dab96aec8390b228cc3733a5eae4b Mon Sep 17 00:00:00 2001 From: divinity76 Date: Tue, 15 Oct 2024 14:31:50 +0200 Subject: [PATCH] Improve error message to include expected network label Updated the error message when a network is found with an incorrect label to also display the expected label value. This provides more context for debugging. Signed-off-by: divinity76 --- pkg/compose/create.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/compose/create.go b/pkg/compose/create.go index f35af06137b..8608ac971c7 100644 --- a/pkg/compose/create.go +++ b/pkg/compose/create.go @@ -1208,7 +1208,13 @@ func (s *composeService) resolveOrCreateNetwork(ctx context.Context, n *types.Ne "Set `external: true` to use an existing network", n.Name, expectedProjectLabel) } if inspect.Labels[api.NetworkLabel] != expectedNetworkLabel { - return fmt.Errorf("network %s was found but has incorrect label %s set to %q", n.Name, api.NetworkLabel, inspect.Labels[api.NetworkLabel]) + return fmt.Errorf( + "network %s was found but has incorrect label %s set to %q (expected: %q)", + n.Name, + api.NetworkLabel, + inspect.Labels[api.NetworkLabel], + expectedNetworkLabel, + ) } return nil }