forked from quic-go/quic-go
add a message to crypto errors
The string representation varies depending on the message: * if there's no message, the TLS alert is used * if there's a message, it is used instead
This commit is contained in:
@@ -31,9 +31,10 @@ func TimeoutError(errorMessage string) *QuicError {
|
||||
}
|
||||
|
||||
// CryptoError create a new QuicError instance for a crypto error
|
||||
func CryptoError(tlsAlert uint8) *QuicError {
|
||||
func CryptoError(tlsAlert uint8, errorMessage string) *QuicError {
|
||||
return &QuicError{
|
||||
ErrorCode: 0x100 + ErrorCode(tlsAlert),
|
||||
ErrorCode: 0x100 + ErrorCode(tlsAlert),
|
||||
ErrorMessage: errorMessage,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,13 @@ var _ = Describe("QUIC Transport Errors", func() {
|
||||
Expect(err.Error()).To(Equal("NO_ERROR: foobar"))
|
||||
})
|
||||
|
||||
It("has a string representation for crypto errors", func() {
|
||||
err := CryptoError(42)
|
||||
It("has a string representation for crypto errors with a message", func() {
|
||||
err := CryptoError(42, "foobar")
|
||||
Expect(err.Error()).To(Equal("CRYPTO_ERROR: foobar"))
|
||||
})
|
||||
|
||||
It("has a string representation for crypto errors without a message", func() {
|
||||
err := CryptoError(42, "")
|
||||
Expect(err.Error()).To(Equal("CRYPTO_ERROR: tls: bad certificate"))
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user