forked from quic-go/quic-go
introduce a qerr.Err{Idle,Handshake}Timeout
This commit is contained in:
@@ -5,6 +5,11 @@ import (
|
||||
"net"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrIdleTimeout = newTimeoutError("No recent network activity")
|
||||
ErrHandshakeTimeout = newTimeoutError("Handshake did not complete in time")
|
||||
)
|
||||
|
||||
// A QuicError consists of an error code plus a error reason
|
||||
type QuicError struct {
|
||||
ErrorCode ErrorCode
|
||||
@@ -33,8 +38,8 @@ func NewErrorWithFrameType(errorCode ErrorCode, frameType uint64, errorMessage s
|
||||
}
|
||||
}
|
||||
|
||||
// NewTimeoutError creates a new QuicError instance for a timeout error
|
||||
func NewTimeoutError(errorMessage string) *QuicError {
|
||||
// newTimeoutError creates a new QuicError instance for a timeout error
|
||||
func newTimeoutError(errorMessage string) *QuicError {
|
||||
return &QuicError{
|
||||
ErrorMessage: errorMessage,
|
||||
isTimeout: true,
|
||||
|
||||
@@ -31,7 +31,7 @@ var _ = Describe("QUIC Transport Errors", func() {
|
||||
})
|
||||
|
||||
It("has a string representation for timeout errors", func() {
|
||||
err := NewTimeoutError("foobar")
|
||||
err := newTimeoutError("foobar")
|
||||
Expect(err.Timeout()).To(BeTrue())
|
||||
Expect(err.Error()).To(Equal("NO_ERROR: foobar"))
|
||||
})
|
||||
|
||||
@@ -667,7 +667,7 @@ runLoop:
|
||||
if s.tracer != nil {
|
||||
s.tracer.ClosedConnection(logging.NewTimeoutCloseReason(logging.TimeoutReasonHandshake))
|
||||
}
|
||||
s.destroyImpl(qerr.NewTimeoutError("Handshake did not complete in time"))
|
||||
s.destroyImpl(qerr.ErrHandshakeTimeout)
|
||||
continue
|
||||
} else {
|
||||
idleTimeoutStartTime := s.idleTimeoutStartTime()
|
||||
@@ -676,7 +676,7 @@ runLoop:
|
||||
if s.tracer != nil {
|
||||
s.tracer.ClosedConnection(logging.NewTimeoutCloseReason(logging.TimeoutReasonIdle))
|
||||
}
|
||||
s.destroyImpl(qerr.NewTimeoutError("No recent network activity"))
|
||||
s.destroyImpl(qerr.ErrIdleTimeout)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user