mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: Use containerd errdefs to convert http errors
Previously, we were using our own `FromStatusCode` function to map HTTP status codes to Docker error types. Switch to the containerd code. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
)
|
||||
|
||||
// FromStatusCode creates an errdef error, based on the provided HTTP status-code
|
||||
//
|
||||
// Deprecated: Use [cerrdefs.ToNative] instead
|
||||
func FromStatusCode(err error, statusCode int) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
|
||||
@@ -83,6 +83,7 @@ func TestFromStatusCode(t *testing.T) {
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(http.StatusText(tc.status), func(t *testing.T) {
|
||||
//nolint:staticcheck // ignore SA1019: FromStatusCode is deprecated
|
||||
err := FromStatusCode(tc.err, tc.status)
|
||||
if !tc.check(err) {
|
||||
t.Errorf("unexpected error-type %T", err)
|
||||
|
||||
Reference in New Issue
Block a user