]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: update for error
authorRuss Cox <rsc@golang.org>
Wed, 2 Nov 2011 01:48:27 +0000 (21:48 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 2 Nov 2011 01:48:27 +0000 (21:48 -0400)
R=golang-dev, iant, r
CC=golang-dev
https://golang.org/cl/5306075

src/pkg/runtime/error.go

index 6c37f888f20b32b6577c20c94c4d3fd0a38e9fe3..13dc52b32aaa52a34ec64b8e5f4020d21787dd56 100644 (file)
@@ -6,7 +6,7 @@ package runtime
 
 // The Error interface identifies a run time error.
 type Error interface {
-       String() string
+       error
 
        // RuntimeError is a no-op function but
        // serves to distinguish types that are runtime
@@ -28,7 +28,7 @@ type TypeAssertionError struct {
 
 func (*TypeAssertionError) RuntimeError() {}
 
-func (e *TypeAssertionError) String() string {
+func (e *TypeAssertionError) Error() string {
        inter := e.interfaceString
        if inter == "" {
                inter = "interface"
@@ -98,7 +98,7 @@ type errorString string
 
 func (e errorString) RuntimeError() {}
 
-func (e errorString) String() string {
+func (e errorString) Error() string {
        return "runtime error: " + string(e)
 }
 
@@ -123,6 +123,8 @@ func printany(i interface{}) {
                print("nil")
        case stringer:
                print(v.String())
+       case error:
+               print(v.Error())
        case int:
                print(v)
        case string: