improve string representation of timeout errors

This commit is contained in:
Marten Seemann
2021-03-23 14:37:49 +08:00
parent 81d16a9903
commit afbb2b7b6a
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() {