forked from TrueCloudLab/frostfs-node
[#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 <evgeniy@nspcc.ru>
This commit is contained in:
parent
f1202a5738
commit
751147793f
1 changed files with 4 additions and 0 deletions
|
@ -2,6 +2,7 @@ package morph
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
"github.com/nspcc-dev/neo-go/pkg/rpc/client"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
@ -10,6 +11,9 @@ import (
|
||||||
func getN3Client(v *viper.Viper) (*client.Client, error) {
|
func getN3Client(v *viper.Viper) (*client.Client, error) {
|
||||||
ctx := context.Background() // FIXME(@fyrchik): timeout context
|
ctx := context.Background() // FIXME(@fyrchik): timeout context
|
||||||
endpoint := v.GetString(endpointFlag)
|
endpoint := v.GetString(endpointFlag)
|
||||||
|
if endpoint == "" {
|
||||||
|
return nil, errors.New("missing endpoint")
|
||||||
|
}
|
||||||
c, err := client.New(ctx, endpoint, client.Options{})
|
c, err := client.New(ctx, endpoint, client.Options{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue