I have a protocol buffer
file:
syntax = "proto3";
package v1api;
option java_multiple_files = true;
option java_package = "myApp.v1";
option java_outer_classname = "V1";
service API {
rpc Login(LoginRequest) returns (LoginResponse)
}
message LoginRequest {
int pin = 1
}
message LoginResponse {
string token = 1
}
I have my server written in Go (a language that can return multiple values), and my client being an Android application.
When I use this protoBuf to generate Go code for server, it is something like:
...
func (c *aPIClient) Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginResponse, error) {
out := new(LoginResponse)
err := grpc.Invoke(ctx, "/v1api.API/Login", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
...
Notice that there are two return values, (*LoginResponse, error)
.
Now, when I use this protoBuf to generate Java code for my Android side, I get something like:
public myApp.v1.LoginResponse login(myApp.v1.LoginRequest request) {
return blockingUnaryCall(getChannel(), METHOD_LOGIN, getCallOptions(), request);
}
Notice that, here, there is just one return value like Java allows, myApp.v1.LoginResponse
.
My question is, in case of an error returned by the server (something like: return nil, err
), how will I get that second return value in my Android side.