]> Cypherpunks repositories - gostls13.git/commitdiff
crypto: include hash number in panic message.
authorAdam Langley <agl@golang.org>
Mon, 5 Aug 2013 18:23:32 +0000 (14:23 -0400)
committerAdam Langley <agl@golang.org>
Mon, 5 Aug 2013 18:23:32 +0000 (14:23 -0400)
In the event that code tries to use a hash function that isn't compiled
in and panics, give the developer a fighting chance of figuring out
which hash function it needed.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12420045

src/pkg/crypto/crypto.go

index 52ec40bc2fc94576c1a3b5ae3728d4fe1e1fe331..4b03628e69297f6ce303d7c8ed65c0f1de5f3987 100644 (file)
@@ -7,6 +7,7 @@ package crypto
 
 import (
        "hash"
+       "strconv"
 )
 
 // Hash identifies a cryptographic hash function that is implemented in another
@@ -59,7 +60,7 @@ func (h Hash) New() hash.Hash {
                        return f()
                }
        }
-       panic("crypto: requested hash function is unavailable")
+       panic("crypto: requested hash function #" + strconv.Itoa(int(h)) + " is unavailable")
 }
 
 // Available reports whether the given hash function is linked into the binary.