github.com/koko1123/flow-go-1@v0.29.6/engine/common/rpc/errors.go (about) 1 package rpc 2 3 import ( 4 "errors" 5 6 "google.golang.org/grpc/codes" 7 "google.golang.org/grpc/status" 8 9 "github.com/koko1123/flow-go-1/storage" 10 ) 11 12 func ConvertStorageError(err error) error { 13 if err == nil { 14 return nil 15 } 16 17 if status.Code(err) == codes.NotFound { 18 // Already converted 19 return err 20 } 21 if errors.Is(err, storage.ErrNotFound) { 22 return status.Errorf(codes.NotFound, "not found: %v", err) 23 } 24 25 return status.Errorf(codes.Internal, "failed to find: %v", err) 26 }