From 94e375c5d1c28b6cdb56a820de0ee87c3fd5a355 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Fri, 15 May 2015 16:34:00 -0700 Subject: [PATCH] Remove unused and duplicate error types Signed-off-by: Derek McGowan (github: dmcgowan) --- registry/client/blob_writer.go | 2 +- registry/client/blob_writer_test.go | 6 ++---- registry/client/errors.go | 28 ---------------------------- 3 files changed, 3 insertions(+), 33 deletions(-) diff --git a/registry/client/blob_writer.go b/registry/client/blob_writer.go index 441511676..06ca87387 100644 --- a/registry/client/blob_writer.go +++ b/registry/client/blob_writer.go @@ -28,7 +28,7 @@ type httpBlobUpload struct { func (hbu *httpBlobUpload) handleErrorResponse(resp *http.Response) error { if resp.StatusCode == http.StatusNotFound { - return &BlobUploadNotFoundError{Location: hbu.location} + return distribution.ErrBlobUploadUnknown } return handleErrorResponse(resp) } diff --git a/registry/client/blob_writer_test.go b/registry/client/blob_writer_test.go index 2e4edc452..0cc20da4f 100644 --- a/registry/client/blob_writer_test.go +++ b/registry/client/blob_writer_test.go @@ -151,10 +151,8 @@ func TestUploadReadFrom(t *testing.T) { if err == nil { t.Fatalf("Expected error when not found") } - if blobErr, ok := err.(*BlobUploadNotFoundError); !ok { - t.Fatalf("Wrong error type %T: %s", err, err) - } else if expected := e + locationPath; blobErr.Location != expected { - t.Fatalf("Unexpected location: %s, expected %s", blobErr.Location, expected) + if err != distribution.ErrBlobUploadUnknown { + t.Fatalf("Wrong error thrown: %s, expected", err, distribution.ErrBlobUploadUnknown) } // 400 valid json diff --git a/registry/client/errors.go b/registry/client/errors.go index 2bb64a449..c4296fa31 100644 --- a/registry/client/errors.go +++ b/registry/client/errors.go @@ -9,34 +9,6 @@ import ( "github.com/docker/distribution/registry/api/v2" ) -// BlobUploadNotFoundError is returned when making a blob upload operation against an -// invalid blob upload location url. -// This may be the result of using a cancelled, completed, or stale upload -// location. -type BlobUploadNotFoundError struct { - Location string -} - -func (e *BlobUploadNotFoundError) Error() string { - return fmt.Sprintf("No blob upload found at Location: %s", e.Location) -} - -// BlobUploadInvalidRangeError is returned when attempting to upload an image -// blob chunk that is out of order. -// This provides the known BlobSize and LastValidRange which can be used to -// resume the upload. -type BlobUploadInvalidRangeError struct { - Location string - LastValidRange int - BlobSize int -} - -func (e *BlobUploadInvalidRangeError) Error() string { - return fmt.Sprintf( - "Invalid range provided for upload at Location: %s. Last Valid Range: %d, Blob Size: %d", - e.Location, e.LastValidRange, e.BlobSize) -} - // UnexpectedHTTPStatusError is returned when an unexpected HTTP status is // returned when making a registry api call. type UnexpectedHTTPStatusError struct {