Skip to content

Commit

Permalink
fix: Return wrapped error from config package
Browse files Browse the repository at this point in the history
  • Loading branch information
kayano committed Dec 21, 2023
1 parent a6eb581 commit e39a698
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ package config

import (
"crypto/tls"
"errors"
"fmt"

"github.com/cosmos/cosmos-sdk/codec"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
)

var errConfig = errors.New("config error")

func configError(msg string) error {
return fmt.Errorf("%w: %s", errConfig, msg)
}

type Config struct {
Addr string `env:"GRPC_ADDR" envDefault:"grpc.constantine.archway.tech:443"`
TLS bool `env:"GRPC_TLS_ENABLED" envDefault:"true"`
Expand All @@ -28,6 +36,9 @@ func (c Config) GRPCConn() (*grpc.ClientConn, error) {
transportCreds,
grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(nil).GRPCCodec())),
)
if err != nil {
return nil, configError(err.Error())
}

return conn, err
return conn, nil
}

0 comments on commit e39a698

Please sign in to comment.