http3: introduce an HTTP/3 error type (#4039)

* http3: introduce an HTTP/3 error type

* http3: use a pointer receiver for the Error
This commit is contained in:
Marten Seemann 2023-09-16 18:57:50 +07:00 committed by GitHub
parent ab1c1be9a9
commit d8cc4cb3ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 125 additions and 12 deletions

View file

@ -307,9 +307,10 @@ var _ = Describe("HTTP tests", func() {
for {
if _, err := w.Write([]byte("foobar")); err != nil {
Expect(r.Context().Done()).To(BeClosed())
var strErr *quic.StreamError
Expect(errors.As(err, &strErr)).To(BeTrue())
Expect(strErr.ErrorCode).To(Equal(quic.StreamErrorCode(0x10c)))
var http3Err *http3.Error
Expect(errors.As(err, &http3Err)).To(BeTrue())
Expect(http3Err.ErrorCode).To(Equal(http3.ErrCode(0x10c)))
Expect(http3Err.Error()).To(Equal("H3_REQUEST_CANCELLED"))
return
}
}
@ -325,7 +326,10 @@ var _ = Describe("HTTP tests", func() {
cancel()
Eventually(handlerCalled).Should(BeClosed())
_, err = resp.Body.Read([]byte{0})
Expect(err).To(HaveOccurred())
var http3Err *http3.Error
Expect(errors.As(err, &http3Err)).To(BeTrue())
Expect(http3Err.ErrorCode).To(Equal(http3.ErrCode(0x10c)))
Expect(http3Err.Error()).To(Equal("H3_REQUEST_CANCELLED (local)"))
})
It("allows streamed HTTP requests", func() {