From 172d98599c3ebee20df04b7647bab2c7037daa39 Mon Sep 17 00:00:00 2001 From: Hannah Shi Date: Thu, 28 May 2020 00:41:30 +0000 Subject: [PATCH] check status->code and print error message --- examples/php/greeter_client.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/php/greeter_client.php b/examples/php/greeter_client.php index bb94a085278..2067ac37d99 100644 --- a/examples/php/greeter_client.php +++ b/examples/php/greeter_client.php @@ -34,10 +34,12 @@ function greet($name) $request = new Helloworld\HelloRequest(); $request->setName($name); list($reply, $status) = $client->SayHello($request)->wait(); - $message = $reply->getMessage(); - - return $message; + if ($status->code !== Grpc\STATUS_OK) { + echo "ERROR: ".$status->code.", ".$status->details."\n"; + exit(1); + } + echo $reply->getMessage()."\n"; } $name = !empty($argv[1]) ? $argv[1] : 'world'; -echo greet($name)."\n"; +greet($name);