Updated namespace_server.go to use GRPCError()

This commit is contained in:
Aleksandr Melnikov
2020-02-10 16:27:28 -08:00
parent 1e7f034384
commit b0cea10a08
2 changed files with 7 additions and 3 deletions

View File

@@ -2,13 +2,12 @@ package server
import (
"context"
"errors"
"github.com/golang/protobuf/ptypes/empty"
"github.com/onepanelio/core/api"
"github.com/onepanelio/core/manager"
"github.com/onepanelio/core/model"
"github.com/onepanelio/core/util"
"google.golang.org/grpc/codes"
)
type NamespaceServer struct {
@@ -30,7 +29,9 @@ func apiNamespace(ns *model.Namespace) (namespace *api.Namespace) {
func (s *NamespaceServer) ListNamespaces(ctx context.Context, empty *empty.Empty) (*api.ListNamespacesResponse, error) {
namespaces, err := s.resourceManager.ListNamespaces()
if err != nil {
return nil, util.NewUserError(codes.Unknown, "Unknown error.")
if errors.As(err, &userError) {
return nil, userError.GRPCError()
}
}
apiNamespaces := []*api.Namespace{}