package keeper

import (
	"context"
	"errors"

	"cosmossdk.io/collections"

	"<%= ModulePath %>/x/<%= ModuleName %>/types"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
)

func (q queryServer) Get<%= TypeName.PascalCase %>(ctx context.Context, req *types.QueryGet<%= TypeName.PascalCase %>Request) (*types.QueryGet<%= TypeName.PascalCase %>Response, error) {
	if req == nil {
		return nil, status.Error(codes.InvalidArgument, "invalid request")
	}

	val, err := q.k.<%= TypeName.UpperCamel %>.Get(ctx)
	if err != nil {
		if errors.Is(err, collections.ErrNotFound) {
			return nil, status.Error(codes.NotFound, "not found")
		}

		return nil, status.Error(codes.Internal, "internal error")
	}

	return &types.QueryGet<%= TypeName.PascalCase %>Response{<%= TypeName.UpperCamel %>: val}, nil
}