1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-07 23:02:12 +02:00

fix example

This commit is contained in:
wei cheng 2019-05-21 13:53:21 +08:00
parent 5d95b333f1
commit 92ac678e8a
No known key found for this signature in database
GPG Key ID: 5AF7E34E6A971D7F

View File

@ -10,13 +10,11 @@ import (
"time"
"github.com/bilibili/kratos/pkg/ecode"
epb "github.com/bilibili/kratos/pkg/ecode/pb"
"github.com/bilibili/kratos/pkg/log"
"github.com/bilibili/kratos/pkg/net/rpc/warden"
pb "github.com/bilibili/kratos/pkg/net/rpc/warden/internal/proto/testproto"
xtime "github.com/bilibili/kratos/pkg/time"
"github.com/golang/protobuf/ptypes"
"google.golang.org/grpc"
)
@ -26,9 +24,7 @@ type helloServer struct {
func (s *helloServer) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) {
if in.Name == "err_detail_test" {
any, _ := ptypes.MarshalAny(&pb.HelloReply{Success: true, Message: "this is test detail"})
err := epb.From(ecode.AccessDenied)
err.ErrDetail = any
err, _ := ecode.Error(ecode.AccessDenied, "AccessDenied").WithDetails(&pb.HelloReply{Success: true, Message: "this is test detail"})
return nil, err
}
return &pb.HelloReply{Message: fmt.Sprintf("hello %s from %s", in.Name, s.addr)}, nil