diff options
author | Ian Lance Taylor <iant@golang.org> | 2020-02-27 11:24:24 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-03-01 02:22:06 +0000 |
commit | 2172b229b95f483324825806f692303a0a132762 (patch) | |
tree | 1876950b18102446ab4762937d2e3579685294e6 /src/runtime/pprof | |
parent | c1abd5ab70e1e8ac59a2960d41fe6d83d68ea69b (diff) | |
download | go-2172b229b95f483324825806f692303a0a132762.tar.gz go-2172b229b95f483324825806f692303a0a132762.zip |
runtime/pprof/internal/profile: make error message readable
The error message for an unrecognized type in decodeField was using
string(i) for an int type i. It was recently changed (by me) to
string(rune(i)), but that just avoided a vet warning without fixing
the problem. This CL fixes the problem by using fmt.Errorf.
We also change the message to "unknown wire type" to match the master
copy of this code in github.com/google/pprof/profile/proto.go.
Updates #32479
Change-Id: Ia91ea6d5edbd7cd946225d1ee96bb7623b52bb44
Reviewed-on: https://go-review.googlesource.com/c/go/+/221384
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Diffstat (limited to 'src/runtime/pprof')
-rw-r--r-- | src/runtime/pprof/internal/profile/proto.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/runtime/pprof/internal/profile/proto.go b/src/runtime/pprof/internal/profile/proto.go index 294acfeb92..52cf1ef2b3 100644 --- a/src/runtime/pprof/internal/profile/proto.go +++ b/src/runtime/pprof/internal/profile/proto.go @@ -21,7 +21,10 @@ package profile -import "errors" +import ( + "errors" + "fmt" +) type buffer struct { field int @@ -232,7 +235,7 @@ func decodeField(b *buffer, data []byte) ([]byte, error) { b.u64 = uint64(le32(data[:4])) data = data[4:] default: - return nil, errors.New("unknown type: " + string(rune(b.typ))) + return nil, fmt.Errorf("unknown wire type: %d", b.typ) } return data, nil |