From cabb840a915565f805108d0a1c50e58ca4dce189 Mon Sep 17 00:00:00 2001 From: yusing Date: Sat, 14 Jun 2025 19:32:36 +0800 Subject: [PATCH] tweak(docker): add hint when specified network not found --- internal/docker/container.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/docker/container.go b/internal/docker/container.go index 219719f..4b13154 100644 --- a/internal/docker/container.go +++ b/internal/docker/container.go @@ -13,6 +13,7 @@ import ( "github.com/docker/go-connections/nat" "github.com/yusing/go-proxy/agent/pkg/agent" config "github.com/yusing/go-proxy/internal/config/types" + "github.com/yusing/go-proxy/internal/gperr" idlewatcher "github.com/yusing/go-proxy/internal/idlewatcher/types" "github.com/yusing/go-proxy/internal/serialization" "github.com/yusing/go-proxy/internal/utils" @@ -247,7 +248,8 @@ func (c *Container) setPrivateHostname(helper containerHelper) { } } } - c.addError(fmt.Errorf("%w: %s", ErrNetworkNotFound, c.Network)) + nearest := gperr.DoYouMean(utils.NearestField(c.Network, helper.NetworkSettings.Networks)) + c.addError(fmt.Errorf("network %q not found, %w", c.Network, nearest)) return } // fallback to first network if no network is specified