1
0
mirror of https://github.com/golang/go synced 2024-11-22 15:04:52 -07:00

net/http: let ErrNotSupported match errors.ErrUnsupported

For #41198

Change-Id: Ibb030e94618a1f594cfd98ddea214ad7a88d2e73
Reviewed-on: https://go-review.googlesource.com/c/go/+/494122
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Ian Lance Taylor 2023-05-10 12:47:06 -07:00 committed by Gopher Robot
parent 945a2b17f3
commit 3d33532d1c
3 changed files with 13 additions and 0 deletions

View File

@ -1 +1,2 @@
pkg errors, var ErrUnsupported error #41198
pkg net/http, method (*ProtocolError) Is(error) bool #41198

View File

@ -48,6 +48,11 @@ type ProtocolError struct {
func (pe *ProtocolError) Error() string { return pe.ErrorString }
// Is lets http.ErrNotSupported match errors.ErrUnsupported.
func (pe *ProtocolError) Is(err error) bool {
return pe == ErrNotSupported && err == errors.ErrUnsupported
}
var (
// ErrNotSupported indicates that a feature is not supported.
//

View File

@ -10,6 +10,7 @@ import (
"context"
"crypto/rand"
"encoding/base64"
"errors"
"fmt"
"io"
"math"
@ -1388,3 +1389,9 @@ func runFileAndServerBenchmarks(b *testing.B, mode testMode, f *os.File, n int64
b.SetBytes(n)
}
}
func TestErrNotSupported(t *testing.T) {
if !errors.Is(ErrNotSupported, errors.ErrUnsupported) {
t.Error("errors.Is(ErrNotSupported, errors.ErrUnsupported) failed")
}
}