private function convertToGoogleException(\Exception $ex)
{
switch ($ex->getCode()) {
case 400:
$exception = Exception\BadRequestException::class;
break;
case 404:
$exception = Exception\NotFoundException::class;
break;
case 409:
$exception = Exception\ConflictException::class;
break;
case 500:
$exception = Exception\ServerException::class;
break;
default:
$exception = Exception\ServiceException::class;
break;
}
return new $exception($this->getExceptionMessage($ex), $ex->getCode(), $ex);
}