diff options
| author | Emmanuel Odeke <emm.odeke@gmail.com> | 2016-03-27 17:29:53 -0700 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-04-10 01:16:30 +0000 |
| commit | e4f1d9cf2e948eb0f0bb91d7c253ab61dfff3a59 (patch) | |
| tree | 3d4cf398d6235b777cb0de186d03369d8d598f2a /src/runtime/error.go | |
| parent | 824d8c10fe5e1026c15cbece41ee372b1fd333f3 (diff) | |
| download | go-e4f1d9cf2e948eb0f0bb91d7c253ab61dfff3a59.tar.xz | |
runtime: make execution error panic values implement the Error interface
Make execution panics implement Error as
mandated by https://golang.org/ref/spec#Run_time_panics,
instead of panics with strings.
Fixes #14965
Change-Id: I7827f898b9b9c08af541db922cc24fa0800ff18a
Reviewed-on: https://go-review.googlesource.com/21214
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/error.go')
| -rw-r--r-- | src/runtime/error.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/runtime/error.go b/src/runtime/error.go index 3e1ec4bc5a..15f6bdf014 100644 --- a/src/runtime/error.go +++ b/src/runtime/error.go @@ -50,6 +50,17 @@ func (e errorString) Error() string { return "runtime error: " + string(e) } +// plainError represents a runtime error described a string without +// the prefix "runtime error: " after invoking errorString.Error(). +// See Issue #14965. +type plainError string + +func (e plainError) RuntimeError() {} + +func (e plainError) Error() string { + return string(e) +} + type stringer interface { String() string } @@ -82,5 +93,5 @@ func printany(i interface{}) { // called from generated code func panicwrap(pkg, typ, meth string) { - panic("value method " + pkg + "." + typ + "." + meth + " called using nil *" + typ + " pointer") + panic(plainError("value method " + pkg + "." + typ + "." + meth + " called using nil *" + typ + " pointer")) } |
