forked from quic-go/quic-go
include the error code in the string for CRYPTO_ERRORs
This commit is contained in:
@@ -85,7 +85,7 @@ func (e ErrorCode) String() string {
|
||||
return "AEAD_LIMIT_REACHED"
|
||||
default:
|
||||
if e.isCryptoError() {
|
||||
return "CRYPTO_ERROR"
|
||||
return fmt.Sprintf("CRYPTO_ERROR (%#x)", uint16(e))
|
||||
}
|
||||
return fmt.Sprintf("unknown error code: %#x", uint16(e))
|
||||
}
|
||||
|
||||
@@ -38,13 +38,13 @@ var _ = Describe("QUIC Transport Errors", func() {
|
||||
|
||||
Context("crypto errors", func() {
|
||||
It("has a string representation for errors with a message", func() {
|
||||
err := NewCryptoError(42, "foobar")
|
||||
Expect(err.Error()).To(Equal("CRYPTO_ERROR: foobar"))
|
||||
err := NewCryptoError(0x42, "foobar")
|
||||
Expect(err.Error()).To(Equal("CRYPTO_ERROR (0x142): foobar"))
|
||||
})
|
||||
|
||||
It("has a string representation for errors without a message", func() {
|
||||
err := NewCryptoError(42, "")
|
||||
Expect(err.Error()).To(Equal("CRYPTO_ERROR: tls: bad certificate"))
|
||||
err := NewCryptoError(0x2a, "")
|
||||
Expect(err.Error()).To(Equal("CRYPTO_ERROR (0x12a): tls: bad certificate"))
|
||||
})
|
||||
|
||||
It("says if an error is a crypto error", func() {
|
||||
@@ -76,8 +76,8 @@ var _ = Describe("QUIC Transport Errors", func() {
|
||||
})
|
||||
|
||||
It("recognizes crypto errors", func() {
|
||||
err := ErrorCode(0x100 + 42)
|
||||
Expect(err.Error()).To(Equal("CRYPTO_ERROR: tls: bad certificate"))
|
||||
err := ErrorCode(0x100 + 0x2a)
|
||||
Expect(err.Error()).To(Equal("CRYPTO_ERROR (0x12a): tls: bad certificate"))
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user