Commit c14f71c7 authored by Russ Cox's avatar Russ Cox

runtime: update for error

R=golang-dev, iant, r
CC=golang-dev
https://golang.org/cl/5306075
parent e67d3c44
...@@ -6,7 +6,7 @@ package runtime ...@@ -6,7 +6,7 @@ package runtime
// The Error interface identifies a run time error. // The Error interface identifies a run time error.
type Error interface { type Error interface {
String() string error
// RuntimeError is a no-op function but // RuntimeError is a no-op function but
// serves to distinguish types that are runtime // serves to distinguish types that are runtime
...@@ -28,7 +28,7 @@ type TypeAssertionError struct { ...@@ -28,7 +28,7 @@ type TypeAssertionError struct {
func (*TypeAssertionError) RuntimeError() {} func (*TypeAssertionError) RuntimeError() {}
func (e *TypeAssertionError) String() string { func (e *TypeAssertionError) Error() string {
inter := e.interfaceString inter := e.interfaceString
if inter == "" { if inter == "" {
inter = "interface" inter = "interface"
...@@ -98,7 +98,7 @@ type errorString string ...@@ -98,7 +98,7 @@ type errorString string
func (e errorString) RuntimeError() {} func (e errorString) RuntimeError() {}
func (e errorString) String() string { func (e errorString) Error() string {
return "runtime error: " + string(e) return "runtime error: " + string(e)
} }
...@@ -123,6 +123,8 @@ func printany(i interface{}) { ...@@ -123,6 +123,8 @@ func printany(i interface{}) {
print("nil") print("nil")
case stringer: case stringer:
print(v.String()) print(v.String())
case error:
print(v.Error())
case int: case int:
print(v) print(v)
case string: case string:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment