From: Robert Griesemer Date: Wed, 8 Apr 2015 19:28:44 +0000 (-0700) Subject: math/big: make ErrNaN actually implement the error interface (oversight) X-Git-Tag: go1.5beta1~1237 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b28802d2f1ba9ef49fc3608d7026a524a98bdddb;p=gostls13.git math/big: make ErrNaN actually implement the error interface (oversight) 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 --- diff --git a/src/math/big/float.go b/src/math/big/float.go index ed55e8e513..35ad2567e7 100644 --- a/src/math/big/float.go +++ b/src/math/big/float.go @@ -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. diff --git a/src/math/big/float_test.go b/src/math/big/float_test.go index 2a48ec4465..5b5a0247b1 100644 --- a/src/math/big/float_test.go +++ b/src/math/big/float_test.go @@ -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 {