Merge pull request #3118 from lucas-clemente/improve-timeout-error-string

improve string representation of timeout errors
This commit is contained in:
Marten Seemann
2021-04-02 17:22:17 +07:00
committed by GitHub
2 changed files with 9 additions and 4 deletions

View File

@@ -65,9 +65,14 @@ func (e *QuicError) Error() string {
}
return fmt.Sprintf("Application error %#x: %s", uint64(e.ErrorCode), e.ErrorMessage)
}
str := e.ErrorCode.String()
if e.FrameType != 0 {
str += fmt.Sprintf(" (frame type: %#x)", e.FrameType)
var str string
if e.isTimeout {
str = "Timeout"
} else {
str = e.ErrorCode.String()
if e.FrameType != 0 {
str += fmt.Sprintf(" (frame type: %#x)", e.FrameType)
}
}
msg := e.ErrorMessage
if len(msg) == 0 {

View File

@@ -33,7 +33,7 @@ var _ = Describe("QUIC Transport Errors", func() {
It("has a string representation for timeout errors", func() {
err := NewTimeoutError("foobar")
Expect(err.Timeout()).To(BeTrue())
Expect(err.Error()).To(Equal("NO_ERROR: foobar"))
Expect(err.Error()).To(Equal("Timeout: foobar"))
})
Context("crypto errors", func() {