From afbb2b7b6a030ee8988665ecb8ec57f905be7b1f Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Tue, 23 Mar 2021 14:37:49 +0800 Subject: [PATCH] improve string representation of timeout errors --- internal/qerr/quic_error.go | 11 ++++++++--- internal/qerr/quic_error_test.go | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/qerr/quic_error.go b/internal/qerr/quic_error.go index 18a26fdb..73ae2e24 100644 --- a/internal/qerr/quic_error.go +++ b/internal/qerr/quic_error.go @@ -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 { diff --git a/internal/qerr/quic_error_test.go b/internal/qerr/quic_error_test.go index 4d547287..ccf294f3 100644 --- a/internal/qerr/quic_error_test.go +++ b/internal/qerr/quic_error_test.go @@ -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() {