Merge pull request #1805 from lucas-clemente/return-timeout-errors

consistently return timeout errors after timeouts
This commit is contained in:
Marten Seemann
2019-03-05 17:31:48 +09:00
committed by GitHub
7 changed files with 167 additions and 18 deletions

View File

@@ -2,6 +2,7 @@ package qerr
import (
"fmt"
"net"
)
// ErrorCode can be used as a normal error without reason.
@@ -17,6 +18,8 @@ type QuicError struct {
ErrorMessage string
}
var _ net.Error = &QuicError{}
// Error creates a new QuicError instance
func Error(errorCode ErrorCode, errorMessage string) *QuicError {
return &QuicError{
@@ -29,6 +32,11 @@ func (e *QuicError) Error() string {
return fmt.Sprintf("%s: %s", e.ErrorCode.String(), e.ErrorMessage)
}
// Temporary says if the error is temporary.
func (e *QuicError) Temporary() bool {
return false
}
// Timeout says if this error is a timeout.
func (e *QuicError) Timeout() bool {
switch e.ErrorCode {