20 lines
		
	
	
		
			355 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			355 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package content
 | 
						|
 | 
						|
import (
 | 
						|
	"github.com/docker/containerd/content"
 | 
						|
	"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
 | 
						|
}
 |