From 751147793f4ce598829d0ad90434ae15f3df1232 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 18 Oct 2021 15:20:04 +0300 Subject: [PATCH] [#927] neofs-adm: provide better error message if endpoint is missing Note that we cannot mark `--rpc-endpoint` flag as required because it can be taken from config. Before: ``` Error: can't create N3 client: failed to get network magic: Post "": unsupported protocol scheme "" ``` Now: ``` Error: can't create N3 client: missing endpoint ``` Signed-off-by: Evgenii Stratonikov --- cmd/neofs-adm/internal/modules/morph/n3client.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/neofs-adm/internal/modules/morph/n3client.go b/cmd/neofs-adm/internal/modules/morph/n3client.go index f3e4c1541..578772d0f 100644 --- a/cmd/neofs-adm/internal/modules/morph/n3client.go +++ b/cmd/neofs-adm/internal/modules/morph/n3client.go @@ -2,6 +2,7 @@ package morph import ( "context" + "errors" "github.com/nspcc-dev/neo-go/pkg/rpc/client" "github.com/spf13/viper" @@ -10,6 +11,9 @@ import ( func getN3Client(v *viper.Viper) (*client.Client, error) { ctx := context.Background() // FIXME(@fyrchik): timeout context endpoint := v.GetString(endpointFlag) + if endpoint == "" { + return nil, errors.New("missing endpoint") + } c, err := client.New(ctx, endpoint, client.Options{}) if err != nil { return nil, err