fix errors.Is for StreamError and DatagramTooLargeError (#4825)

This commit is contained in:
Marten Seemann
2024-12-29 17:56:38 +08:00
committed by GitHub
parent 46546ce497
commit eec74b14c6
3 changed files with 55 additions and 14 deletions

View File

@@ -50,8 +50,8 @@ type StreamError struct {
}
func (e *StreamError) Is(target error) bool {
_, ok := target.(*StreamError)
return ok
t, ok := target.(*StreamError)
return ok && e.StreamID == t.StreamID && e.ErrorCode == t.ErrorCode && e.Remote == t.Remote
}
func (e *StreamError) Error() string {
@@ -68,8 +68,8 @@ type DatagramTooLargeError struct {
}
func (e *DatagramTooLargeError) Is(target error) bool {
_, ok := target.(*DatagramTooLargeError)
return ok
t, ok := target.(*DatagramTooLargeError)
return ok && e.MaxDatagramPayloadSize == t.MaxDatagramPayloadSize
}
func (e *DatagramTooLargeError) Error() string { return "DATAGRAM frame too large" }