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
7 changed files with 125 additions and 12 deletions

View File

@@ -30,6 +30,14 @@ const (
)
func (e ErrCode) String() string {
s := e.string()
if s != "" {
return s
}
return fmt.Sprintf("unknown error code: %#x", uint16(e))
}
func (e ErrCode) string() string {
switch e {
case ErrCodeNoError:
return "H3_NO_ERROR"
@@ -68,6 +76,6 @@ func (e ErrCode) String() string {
case ErrCodeDatagramError:
return "H3_DATAGRAM_ERROR"
default:
return fmt.Sprintf("unknown error code: %#x", uint16(e))
return ""
}
}