From 6b8185f8eaf89899f82a1b2d61dbc19c18b402dc Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Mon, 20 Sep 2021 03:30:14 -0700 Subject: [PATCH] Correctly wraps errors instead of wrapping error strings Signed-off-by: Bogdan Drutu --- service/internal/builder/exporters_builder.go | 2 +- service/internal/builder/pipelines_builder.go | 2 +- service/parserprovider/file.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/service/internal/builder/exporters_builder.go b/service/internal/builder/exporters_builder.go index 38d75b63a42..0a44fafdd5e 100644 --- a/service/internal/builder/exporters_builder.go +++ b/service/internal/builder/exporters_builder.go @@ -251,7 +251,7 @@ func buildExporter( // Could not create because this exporter does not support this data type. return nil, exporterTypeMismatchErr(cfg, requirement.requiredBy, dataType) } - return nil, fmt.Errorf("error creating %v exporter: %v", cfg.ID(), err) + return nil, fmt.Errorf("error creating %v exporter: %w", cfg.ID(), err) } // Check if the factory really created the exporter. diff --git a/service/internal/builder/pipelines_builder.go b/service/internal/builder/pipelines_builder.go index a8930b0af94..a6ea53f6c5f 100644 --- a/service/internal/builder/pipelines_builder.go +++ b/service/internal/builder/pipelines_builder.go @@ -199,7 +199,7 @@ func (pb *pipelinesBuilder) buildPipeline(ctx context.Context, pipelineCfg *conf } if err != nil { - return nil, fmt.Errorf("error creating processor %q in pipeline %q: %v", + return nil, fmt.Errorf("error creating processor %q in pipeline %q: %w", procID, pipelineCfg.Name, err) } diff --git a/service/parserprovider/file.go b/service/parserprovider/file.go index a3c7007229c..6b413a372e6 100644 --- a/service/parserprovider/file.go +++ b/service/parserprovider/file.go @@ -38,7 +38,7 @@ func (fl *fileProvider) Get(context.Context) (*configparser.ConfigMap, error) { cp, err := configparser.NewConfigMapFromFile(fileName) if err != nil { - return nil, fmt.Errorf("error loading config file %q: %v", fileName, err) + return nil, fmt.Errorf("error loading config file %q: %w", fileName, err) } return cp, nil