def RequestWithErrHandling(*args, **kwargs): try: return orig_request(*args, **kwargs) except client.AccessTokenRefreshError as e: log.debug('Exception caught during HTTP request: %s', e.message, exc_info=True) raise store.TokenRefreshError(e.message)
def testJSONWithRefreshError(self): self.refresh_mock.side_effect = store.TokenRefreshError( 'Can not refresh') json_key_file = self._GetTestDataPathFor( 'inactive_service_account.json') # Make sure refresh error propogates out of the command. with self.assertRaises(store.TokenRefreshError): self.Run('auth activate-service-account --key-file={0}'.format( json_key_file))
def _HandleAuthError(e): """Handle a generic auth error and raise a nicer message. Args: e: The exception that was caught. Raises: sore.TokenRefreshError: If an auth error occurs. """ msg = six.text_type(e) log.debug('Exception caught during HTTP request: %s', msg, exc_info=True) raise store.TokenRefreshError(msg)
def _GetTokenRefreshError(exc): from googlecloudsdk.core.credentials import store return store.TokenRefreshError(exc)