summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorSebastiaan van Stijn <github@gone.nl>2022-07-09 00:54:36 +0200
committerSebastiaan van Stijn <github@gone.nl>2022-07-09 00:54:36 +0200
commitee230d8fdda6a1901c2adc394b5fb8471ec7aa51 (patch)
tree3eee1a450431ad966fda466b3ab8f3b1b9148df6 /client
parent5daceee6cab9fe5cf8580220d63a27db107d1cfa (diff)
downloaddocker-ee230d8fdda6a1901c2adc394b5fb8471ec7aa51.tar.gz
client: errors: remove dead code
- Update IsErrNotFound() to check for the current type before falling back to detecting the deprecated type. - Remove unauthorizedError and notImplementedError types, which were not used. - IsErrPluginPermissionDenied() was added in 7c36a1af031b510cd990cf488ee5998a3efb450f, but not used at the time, and still appears to be unused. - Deprecate IsErrUnauthorized in favor of errdefs.IsUnauthorized() - Deprecate IsErrNotImplemented in favor of errdefs,IsNotImplemented() Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'client')
-rw-r--r--client/errors.go45
1 files changed, 7 insertions, 38 deletions
diff --git a/client/errors.go b/client/errors.go
index 257921cebb..e5a8a865f9 100644
--- a/client/errors.go
+++ b/client/errors.go
@@ -40,11 +40,11 @@ type notFound interface {
// IsErrNotFound returns true if the error is a NotFound error, which is returned
// by the API when some object is not found.
func IsErrNotFound(err error) bool {
- var e notFound
- if errors.As(err, &e) {
+ if errdefs.IsNotFound(err) {
return true
}
- return errdefs.IsNotFound(err)
+ var e notFound
+ return errors.As(err, &e)
}
type objectNotFoundError struct {
@@ -58,22 +58,11 @@ func (e objectNotFoundError) Error() string {
return fmt.Sprintf("Error: No such %s: %s", e.object, e.id)
}
-// unauthorizedError represents an authorization error in a remote registry.
-type unauthorizedError struct {
- cause error
-}
-
-// Error returns a string representation of an unauthorizedError
-func (u unauthorizedError) Error() string {
- return u.cause.Error()
-}
-
// IsErrUnauthorized returns true if the error is caused
// when a remote registry authentication fails
+//
+// Deprecated: use errdefs.IsUnauthorized
func IsErrUnauthorized(err error) bool {
- if _, ok := err.(unauthorizedError); ok {
- return ok
- }
return errdefs.IsUnauthorized(err)
}
@@ -85,32 +74,12 @@ func (e pluginPermissionDenied) Error() string {
return "Permission denied while installing plugin " + e.name
}
-// IsErrPluginPermissionDenied returns true if the error is caused
-// when a user denies a plugin's permissions
-func IsErrPluginPermissionDenied(err error) bool {
- _, ok := err.(pluginPermissionDenied)
- return ok
-}
-
-type notImplementedError struct {
- message string
-}
-
-func (e notImplementedError) Error() string {
- return e.message
-}
-
-func (e notImplementedError) NotImplemented() bool {
- return true
-}
-
// IsErrNotImplemented returns true if the error is a NotImplemented error.
// This is returned by the API when a requested feature has not been
// implemented.
+//
+// Deprecated: use errdefs.IsNotImplemented
func IsErrNotImplemented(err error) bool {
- if _, ok := err.(notImplementedError); ok {
- return ok
- }
return errdefs.IsNotImplemented(err)
}