There isn't currently a convenience API for doing this at the Ruby server but it is possible, by doing something like what is done in this test server: https://github.com/grpc/grpc/blob/fa02ab8d3fc961f8a155412655c21a9659efa29d/src/ruby/spec/google_rpc_status_utils_spec.rb#L128
I.e., you can create a Google::Rpc::Status protobuf, and then pack the serialized version of it into status details, as in https://github.com/grpc/grpc/blob/fa02ab8d3fc961f8a155412655c21a9659efa29d/src/ruby/spec/google_rpc_status_utils_spec.rb#L135. Does that help? On Tuesday, August 6, 2019 at 12:26:43 PM UTC-7 Connor Taffe wrote: > At work we're standardizing on using the Richer Error Model > <https://www.grpc.io/docs/guides/error/#richer-error-model> and had > success using it in Go with the errdetails > <https://godoc.org/google.golang.org/genproto/googleapis/rpc/errdetails> > package and WithDetails > <https://godoc.org/google.golang.org/grpc/status#Status.WithDetails> method. > However, we also write a lot of Ruby. In Ruby, it's not documented how you > would attach details > <https://cloud.google.com/apis/design/errors#error_model> to the status. > Is it possible to attach error details using the error classes > <https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/errors.rb#L30> > e.g. GRPC::InvalidArgument? If not, is it possible to write my own error > classes which would allow attaching details? > > For example perhaps I can create an API like this? > raise GRPC::InvalidArgument.new( > "foo.bar must only contain alphanumeric characters", > details: Google::Rpc::BadRequest.new( > field_violations: [ > Google::Rpc::BadRequest::FieldViolation.new( > field: "foo.bar", > description: "must only contain alphanumeric characters" > ) > ] > ) > ) > > > -- 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/f1f96d7a-6b5f-4f2c-9570-15078fde6593n%40googlegroups.com.
