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