From acd54e7c19dd0e291211ca59de60be1379fe45b6 Mon Sep 17 00:00:00 2001 From: Hannah Shi Date: Wed, 3 Jun 2020 22:59:51 +0000 Subject: [PATCH] better error checking in ruby helloworld greeter_client --- examples/ruby/greeter_client.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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