2017-03-01 01:10:59 +00:00
|
|
|
package content
|
|
|
|
|
|
|
|
import (
|
2017-04-03 20:14:15 +00:00
|
|
|
"github.com/containerd/containerd/content"
|
2017-03-01 01:10:59 +00:00
|
|
|
"github.com/pkg/errors"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
"google.golang.org/grpc/codes"
|
|
|
|
)
|
|
|
|
|
|
|
|
func rewriteGRPCError(err error) error {
|
|
|
|
switch grpc.Code(errors.Cause(err)) {
|
|
|
|
case codes.AlreadyExists:
|
|
|
|
return content.ErrExists
|
|
|
|
case codes.NotFound:
|
|
|
|
return content.ErrNotFound
|
|
|
|
}
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|