@@ -43,6 +43,7 @@ import (
4343 "github.com/containerd/containerd/content"
4444 contentproxy "github.com/containerd/containerd/content/proxy"
4545 "github.com/containerd/containerd/defaults"
46+ "github.com/containerd/containerd/errdefs"
4647 "github.com/containerd/containerd/events"
4748 "github.com/containerd/containerd/images"
4849 "github.com/containerd/containerd/leases"
@@ -134,7 +135,7 @@ func New(address string, opts ...ClientOpt) (*Client, error) {
134135 c .conn , c .connector = conn , connector
135136 }
136137 if copts .services == nil && c .conn == nil {
137- return nil , errors . New ( "no grpc connection or services is available" )
138+ return nil , errdefs . ErrNoGRPCAndService
138139 }
139140
140141 // check namespace labels for default runtime
@@ -199,7 +200,7 @@ type Client struct {
199200// Reconnect re-establishes the GRPC connection to the containerd daemon
200201func (c * Client ) Reconnect () error {
201202 if c .connector == nil {
202- return errors . New ( "unable to reconnect to containerd, no connector available" )
203+ return errdefs . ErrReconnectFailed
203204 }
204205 c .connMu .Lock ()
205206 defer c .connMu .Unlock ()
@@ -222,7 +223,7 @@ func (c *Client) IsServing(ctx context.Context) (bool, error) {
222223 c .connMu .Lock ()
223224 if c .conn == nil {
224225 c .connMu .Unlock ()
225- return false , errors . New ( "no grpc connection available" )
226+ return false , errdefs . ErrNoGRPC
226227 }
227228 c .connMu .Unlock ()
228229 r , err := c .HealthService ().Check (ctx , & grpc_health_v1.HealthCheckRequest {}, grpc .WaitForReady (true ))
@@ -354,7 +355,7 @@ func (c *Client) Fetch(ctx context.Context, ref string, opts ...RemoteOpt) (imag
354355 }
355356
356357 if fetchCtx .Unpack {
357- return images.Image {}, errors . New ( "unpack on fetch not supported, try pull" )
358+ return images.Image {}, errdefs . ErrUnpackNotSupported
358359 }
359360
360361 if fetchCtx .PlatformMatcher == nil {
@@ -642,7 +643,7 @@ func (c *Client) Version(ctx context.Context) (Version, error) {
642643 c .connMu .Lock ()
643644 if c .conn == nil {
644645 c .connMu .Unlock ()
645- return Version {}, errors . New ( "no grpc connection available" )
646+ return Version {}, errdefs . ErrNoGRPC
646647 }
647648 c .connMu .Unlock ()
648649 response , err := c .VersionService ().Version (ctx , & ptypes.Empty {})
0 commit comments