According to gRPC Error Handing <https://grpc.io/docs/guides/error/>, Richer 
error model contains much more information than the standard one comes with 
gRPC default. So I decided to use it for my gRPC servers for Errors.

In Java, I am able to easily use it and return Error in response as 

Status status = Status.newBuilder()
        .setCode(Code.INVALID_ARGUMENT.getNumber())
        .setMessage("Required argument is empty.")
        .addDetails(Any.pack(DebugInfo.newBuilder().addStackEntries("This 
is a sample stack trace").build()))
        .build();
      
responseObserver.onError(StatusProto.toStatusRuntimeException(status));

However, I also have gRPC servers which are written in Ruby. And I can't 
find a way to raise an exception or return error status as in Java.

I did this:

    debug_info = Google::Rpc::DebugInfo.new(
      stack_entries: ["1", "2"] ,
    )

    error_status = Google::Rpc::Status.new(
      code: 3,
      message: "msg",
      details: [Google::Protobuf::Any.pack(debug_info)]
    )
# no way for me to throw exception from error_status

After i initialized a Google::Rpc::Status instance, it seems like there is 
no way for me to raise an exception from error_status I created. Anyone has 
any idea how I can do it in Ruby? Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/f09e32f4-b008-4e43-9789-e9d871c015b1%40googlegroups.com.

Reply via email to