]> Cypherpunks repositories - gostls13.git/commitdiff
math/big: make ErrNaN actually implement the error interface (oversight)
authorRobert Griesemer <gri@golang.org>
Wed, 8 Apr 2015 19:28:44 +0000 (12:28 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 8 Apr 2015 19:47:39 +0000 (19:47 +0000)
There was no way to get to the error message before.

Change-Id: I4aa9d3d9f468c33f9996295bafcbed097de0389f
Reviewed-on: https://go-review.googlesource.com/8660
Reviewed-by: Alan Donovan <adonovan@google.com>
src/math/big/float.go
src/math/big/float_test.go

index ed55e8e5135da469f74f25129abeb106fd82bfec..35ad2567e710195092569c5f6217a592424e1872 100644 (file)
@@ -71,6 +71,11 @@ type ErrNaN struct {
        msg string
 }
 
+// ErrNan implements the error interface.
+func (err ErrNaN) Error() string {
+       return err.msg
+}
+
 // NewFloat allocates and returns a new Float set to x,
 // with precision 53 and rounding mode ToNearestEven.
 // NewFloat panics with ErrNaN if x is a NaN.
index 2a48ec44651477558d01cd92d1cc1d0b6ee8821b..5b5a0247b17962d6ef121a3b8ed3a44a5d5b53a6 100644 (file)
@@ -12,6 +12,9 @@ import (
        "testing"
 )
 
+// Verify that ErrNaN implements the error interface.
+var _ error = ErrNaN{}
+
 func (x *Float) uint64() uint64 {
        u, acc := x.Uint64()
        if acc != Exact {