]> Cypherpunks repositories - gostls13.git/commit
reflect: give type hints in error messages
authorJean de Klerk <deklerk@google.com>
Thu, 20 Jun 2019 00:02:09 +0000 (18:02 -0600)
committerIan Lance Taylor <iant@golang.org>
Wed, 18 Sep 2019 20:18:01 +0000 (20:18 +0000)
commit09824ccfe5dce385e4f02894883b635a52a30cac
tree4873bd4ac419271410c6aabb1515e26d5d20c935
parent3c6eaa7c0dd93ad40a46940c4d7a62d966de82e7
reflect: give type hints in error messages

Currently, if you call various reflect methods you might get a panic with a
message like, "reflect: Field of non-struct type". Sometimes it's easy to
grok what's going on, but other times you need to laboriously go perform
reflect.ValueOf(myType).Kind().

This CL just adds that detail to the error message, saving debuggers the
extra step and making the error message more clear.

Change-Id: I7e0c211a3001e6b217b828cbcf50518080b5cb1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/183097
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/reflect/type.go