fixed the problem that grpc client Parser didn't return the correct error info of grpc standard error model

This commit is contained in:
York.GU 2019-09-06 21:54:58 +08:00
parent 1c3091af7d
commit c17c49c48b

View File

@ -78,7 +78,9 @@ class Parser
return ['No response', self::GRPC_ERROR_NO_RESPONSE, $response];
}
if ($response->statusCode !== 200) {
return ['Http status Error', $response->errCode ?: $response->statusCode, $response];
$message = $response->headers['grpc-message'] ?? 'Http status Error';
$code = $response->headers['grpc-status'] ?? ($response->errCode ?: $response->statusCode);
return [$message, (int)$code, $response];
}
$grpc_status = (int) ($response->headers['grpc-status'] ?? 0);
if ($grpc_status !== 0) {