diff --git a/examples/ruby/greeter_client.rb b/examples/ruby/greeter_client.rb index 56b41e370d6..2b602e59fb1 100755 --- a/examples/ruby/greeter_client.rb +++ b/examples/ruby/greeter_client.rb @@ -29,8 +29,12 @@ def main user = ARGV.size > 0 ? ARGV[0] : 'world' hostname = ARGV.size > 1 ? ARGV[1] : 'localhost:50051' stub = Helloworld::Greeter::Stub.new(hostname, :this_channel_is_insecure) - message = stub.say_hello(Helloworld::HelloRequest.new(name: user)).message - p "Greeting: #{message}" + begin + message = stub.say_hello(Helloworld::HelloRequest.new(name: user)).message + p "Greeting: #{message}" + rescue GRPC::BadStatus => e + abort "ERROR: #{e.code}, #{e.details}" + end end main