def _run_request(self, request): """Run API request and handle any errors. Args: request: An apiclient.http.HttpRequest object. Returns: Dictionary results of the API call. Raises: GceError: Raised if API call fails. GceTokenError: Raised if there's a failure refreshing the access token. """ result = {} try: result = request.execute() except httplib2.HttpLib2Error, e: logging.error(e) raise error.GceError('Transport Error occurred')
""" result = {} try: result = request.execute() except httplib2.HttpLib2Error, e: logging.error(e) raise error.GceError('Transport Error occurred') except client.AccessTokenRefreshError, e: logging.error(e) raise error.GceTokenError('Access Token refresh error') except api_errors.BatchError, e: logging.error(e) logging.error('BatchError: %s %s' % (e.resp.status, e.content)) if e.resp.status != 200: raise error.GceError('Batch Error: %s %s' % (e.resp.status, e.resp.reason)) except api_errors.HttpError, e: logging.error(e) raise error.GceError('HttpError: %s %s' % (e.resp.status, e.resp.reason)) return result def _batch_response(self, request_id, response, exception): """Log information about the batch request response. Args: request_id: The string request id. response: A deserialized response object. exception: An apiclient.errors.HttpError exception object if an error occurred while processing the request. """