forked from quic-go/quic-go
rename NewQuicError to Error
This commit is contained in:
@@ -27,7 +27,7 @@ func (u *packetUnpacker) Unpack(publicHeaderBinary []byte, hdr *publicHeader, r
|
||||
plaintext, err := u.aead.Open(hdr.PacketNumber, publicHeaderBinary, ciphertext)
|
||||
if err != nil {
|
||||
// Wrap err in quicError so that public reset is sent by session
|
||||
return nil, protocol.NewQuicError(errorcodes.DecryptionFailure, err.Error())
|
||||
return nil, protocol.Error(errorcodes.DecryptionFailure, err.Error())
|
||||
}
|
||||
r = bytes.NewReader(plaintext)
|
||||
|
||||
@@ -71,7 +71,7 @@ ReadLoop:
|
||||
case 0x07:
|
||||
frame, err = frames.ParsePingFrame(r)
|
||||
default:
|
||||
err = protocol.NewQuicError(errorcodes.InvalidFrameData, fmt.Sprintf("unknown type byte 0x%x", typeByte))
|
||||
err = protocol.Error(errorcodes.InvalidFrameData, fmt.Sprintf("unknown type byte 0x%x", typeByte))
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
@@ -6,8 +6,8 @@ type QuicError struct {
|
||||
ErrorMessage string
|
||||
}
|
||||
|
||||
// NewQuicError creates a new Quic Error
|
||||
func NewQuicError(errorCode ErrorCode, errorMessage string) *QuicError {
|
||||
// Error creates a new Quic Error
|
||||
func Error(errorCode ErrorCode, errorMessage string) *QuicError {
|
||||
return &QuicError{
|
||||
ErrorCode: errorCode,
|
||||
ErrorMessage: errorMessage,
|
||||
|
||||
@@ -161,7 +161,7 @@ func (s *Session) run() {
|
||||
case <-s.aeadChanged:
|
||||
s.tryDecryptingQueuedPackets()
|
||||
case <-time.After(s.connectionParametersManager.GetIdleConnectionStateLifetime()):
|
||||
s.Close(protocol.NewQuicError(errorcodes.NetworkIdleTimeout, "No recent network activity."), true)
|
||||
s.Close(protocol.Error(errorcodes.NetworkIdleTimeout, "No recent network activity."), true)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -363,7 +363,7 @@ func (s *Session) Close(e error, sendConnectionClose bool) error {
|
||||
}
|
||||
|
||||
if e == nil {
|
||||
e = protocol.NewQuicError(errorcodes.PeerGoingAway, "peer going away")
|
||||
e = protocol.Error(errorcodes.PeerGoingAway, "peer going away")
|
||||
}
|
||||
utils.Errorf("Closing session with error: %s", e.Error())
|
||||
|
||||
@@ -621,7 +621,7 @@ func (s *Session) congestionAllowsSending() bool {
|
||||
func (s *Session) tryQueueingUndecryptablePacket(p receivedPacket) {
|
||||
utils.Debugf("Queueing packet 0x%x for later decryption", p.publicHeader.PacketNumber)
|
||||
if len(s.undecryptablePackets)+1 >= protocol.MaxUndecryptablePackets {
|
||||
s.Close(protocol.NewQuicError(errorcodes.DecryptionFailure, "too many undecryptable packets received"), true)
|
||||
s.Close(protocol.Error(errorcodes.DecryptionFailure, "too many undecryptable packets received"), true)
|
||||
}
|
||||
s.undecryptablePackets = append(s.undecryptablePackets, p)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user