private function convertToGoogleException(ApiException $ex)
{
switch ($ex->getCode()) {
case Grpc\STATUS_INVALID_ARGUMENT:
$exception = Exception\BadRequestException::class;
break;
case Grpc\STATUS_NOT_FOUND:
$exception = Exception\NotFoundException::class;
break;
case Grpc\STATUS_ALREADY_EXISTS:
$exception = Exception\ConflictException::class;
break;
case Grpc\STATUS_UNKNOWN:
$exception = Exception\ServerException::class;
break;
case Grpc\STATUS_INTERNAL:
$exception = Exception\ServerException::class;
break;
default:
$exception = Exception\ServiceException::class;
break;
}
return new $exception($ex->getMessage(), $ex->getCode(), $ex);
}