exceptions.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Copyright 2016 Google LLC
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. """Exceptions used in the google.auth package."""
  15. class GoogleAuthError(Exception):
  16. """Base class for all google.auth errors."""
  17. class TransportError(GoogleAuthError):
  18. """Used to indicate an error occurred during an HTTP request."""
  19. class RefreshError(GoogleAuthError):
  20. """Used to indicate that an refreshing the credentials' access token
  21. failed."""
  22. class UserAccessTokenError(GoogleAuthError):
  23. """Used to indicate ``gcloud auth print-access-token`` command failed."""
  24. class DefaultCredentialsError(GoogleAuthError):
  25. """Used to indicate that acquiring default credentials failed."""
  26. class MutualTLSChannelError(GoogleAuthError):
  27. """Used to indicate that mutual TLS channel creation is failed, or mutual
  28. TLS channel credentials is missing or invalid."""
  29. class ClientCertError(GoogleAuthError):
  30. """Used to indicate that client certificate is missing or invalid."""
  31. class OAuthError(GoogleAuthError):
  32. """Used to indicate an error occurred during an OAuth related HTTP
  33. request."""
  34. class ReauthFailError(RefreshError):
  35. """An exception for when reauth failed."""
  36. def __init__(self, message=None):
  37. super(ReauthFailError, self).__init__(
  38. "Reauthentication failed. {0}".format(message)
  39. )