Skip to content

Commit

Permalink
Wrap errors
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <ploffay@redhat.com>
  • Loading branch information
pavolloffay committed Feb 8, 2019
1 parent b458a8b commit b2fa5f9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions plugin/storage/es/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"path/filepath"
"strings"

"github.com/pkg/errors"
"github.com/spf13/viper"
"github.com/uber/jaeger-lib/metrics"
"go.uber.org/zap"
Expand Down Expand Up @@ -76,14 +77,12 @@ func (f *Factory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger)

primaryClient, err := f.primaryConfig.NewClient(logger, metricsFactory)
if err != nil {
f.logger.Error("failed to create primary Elasticsearch client", zap.Error(err))
return err
return errors.Wrap(err, "failed to create primary Elasticsearch client")
}
f.primaryClient = primaryClient
archiveClient, err := f.archiveConfig.NewClient(logger, metricsFactory)
if err != nil {
f.logger.Error("failed to create archive Elasticsearch client", zap.Error(err))
return err
return errors.Wrap(err, "failed to create archive Elasticsearch client")
}
f.archiveClient = archiveClient
return nil
Expand Down
4 changes: 2 additions & 2 deletions plugin/storage/es/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ func TestElasticsearchFactory(t *testing.T) {
// after InitFromViper, f.primaryConfig points to a real session builder that will fail in unit tests,
// so we override it with a mock.
f.primaryConfig = &mockClientBuilder{err: errors.New("made-up error")}
assert.EqualError(t, f.Initialize(metrics.NullFactory, zap.NewNop()), "made-up error")
assert.EqualError(t, f.Initialize(metrics.NullFactory, zap.NewNop()), "failed to create primary Elasticsearch client: made-up error")

f.primaryConfig = &mockClientBuilder{}
f.archiveConfig = &mockClientBuilder{err: errors.New("made-up error2")}
assert.EqualError(t, f.Initialize(metrics.NullFactory, zap.NewNop()), "made-up error2")
assert.EqualError(t, f.Initialize(metrics.NullFactory, zap.NewNop()), "failed to create archive Elasticsearch client: made-up error2")

f.archiveConfig = &mockClientBuilder{}
assert.NoError(t, f.Initialize(metrics.NullFactory, zap.NewNop()))
Expand Down
2 changes: 1 addition & 1 deletion plugin/storage/es/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func addFlags(flagSet *flag.FlagSet, nsConfig *namespaceConfig) {
flagSet.String(
nsConfig.namespace+suffixTokenPath,
nsConfig.TokenFilePath,
"Path to a file containing bearer token. This flag also uses "+suffixCA+" if it is specified")
"Path to a file containing bearer token. This flag also uses CA if it is specified")
flagSet.Bool(
nsConfig.namespace+suffixSniffer,
nsConfig.Sniffer,
Expand Down

0 comments on commit b2fa5f9

Please sign in to comment.