check status->code and print error message

pull/23062/head
Hannah Shi 5 years ago
parent c9ed65f469
commit 172d98599c
  1. 10
      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);

Loading…
Cancel
Save