From 543f3aea97465cb753af6e96f9d4de08371a3e86 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 23 Sep 2020 22:46:24 +0300 Subject: [PATCH] all: consistently use "%w" formatting in fmt.Errorf for wrapped errors --- app/vmalert/config/config.go | 2 +- app/vmstorage/transport/server.go | 2 +- lib/promscrape/discovery/ec2/api_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/vmalert/config/config.go b/app/vmalert/config/config.go index f027dad59..cd40af7af 100644 --- a/app/vmalert/config/config.go +++ b/app/vmalert/config/config.go @@ -41,7 +41,7 @@ func (g *Group) UnmarshalYAML(unmarshal func(interface{}) error) error { } b, err := yaml.Marshal(g) if err != nil { - return fmt.Errorf("failed to marshal group configuration for checksum: %s", err) + return fmt.Errorf("failed to marshal group configuration for checksum: %w", err) } h := md5.New() h.Write(b) diff --git a/app/vmstorage/transport/server.go b/app/vmstorage/transport/server.go index cc5bdecbc..ea6f52fea 100644 --- a/app/vmstorage/transport/server.go +++ b/app/vmstorage/transport/server.go @@ -724,7 +724,7 @@ func (s *Server) processVMSelectTagValueSuffixes(ctx *vmselectRequestCtx) error tagValuePrefix := append([]byte{}, ctx.dataBuf...) delimiter, err := ctx.readByte() if err != nil { - return fmt.Errorf("cannot read delimiter: %s", err) + return fmt.Errorf("cannot read delimiter: %w", err) } // Search for tag value suffixes diff --git a/lib/promscrape/discovery/ec2/api_test.go b/lib/promscrape/discovery/ec2/api_test.go index a37c33ce5..b067880b1 100644 --- a/lib/promscrape/discovery/ec2/api_test.go +++ b/lib/promscrape/discovery/ec2/api_test.go @@ -114,7 +114,7 @@ func TestParseARNCredentialsSuccess(t *testing.T) { func mustParseRFC3339(s string) time.Time { expTime, err := time.Parse(time.RFC3339, s) if err != nil { - panic(fmt.Errorf("unexpected error when parsing time from %q: %s", s, err)) + panic(fmt.Errorf("unexpected error when parsing time from %q: %w", s, err)) } return expTime }