gRPC server error handler golang

You need to return empty model.Model object in order for protobufs to be able to properly serialise the message.

Try

import "google.golang.org/grpc/status"

func (Abcd) Dosomethink(c context.Context, sessionRequest *model.MyModel) (*model.Model, error) {

   return &model.Model{}, status.Error(400,"Default error message for 400")
}

Error Handler:

"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
return data, status.Errorf(
            codes.InvalidArgument,
            fmt.Sprintf("Your message", req.data),
        )

For need more info about the error handling take a look below links.

https://grpc.io/docs/guides/error.html

http://avi.im/grpc-errors/

Tags:

Http

Go

Grpc

Protoc