Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/google/auth/exceptions.py: 79%
29 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:51 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-12-08 06:51 +0000
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.
15"""Exceptions used in the google.auth package."""
18class GoogleAuthError(Exception):
19 """Base class for all google.auth errors."""
21 def __init__(self, *args, **kwargs):
22 super(GoogleAuthError, self).__init__(*args)
23 retryable = kwargs.get("retryable", False)
24 self._retryable = retryable
26 @property
27 def retryable(self):
28 return self._retryable
31class TransportError(GoogleAuthError):
32 """Used to indicate an error occurred during an HTTP request."""
35class RefreshError(GoogleAuthError):
36 """Used to indicate that an refreshing the credentials' access token
37 failed."""
40class UserAccessTokenError(GoogleAuthError):
41 """Used to indicate ``gcloud auth print-access-token`` command failed."""
44class DefaultCredentialsError(GoogleAuthError):
45 """Used to indicate that acquiring default credentials failed."""
48class MutualTLSChannelError(GoogleAuthError):
49 """Used to indicate that mutual TLS channel creation is failed, or mutual
50 TLS channel credentials is missing or invalid."""
53class ClientCertError(GoogleAuthError):
54 """Used to indicate that client certificate is missing or invalid."""
56 @property
57 def retryable(self):
58 return False
61class OAuthError(GoogleAuthError):
62 """Used to indicate an error occurred during an OAuth related HTTP
63 request."""
66class ReauthFailError(RefreshError):
67 """An exception for when reauth failed."""
69 def __init__(self, message=None, **kwargs):
70 super(ReauthFailError, self).__init__(
71 "Reauthentication failed. {0}".format(message), **kwargs
72 )
75class ReauthSamlChallengeFailError(ReauthFailError):
76 """An exception for SAML reauth challenge failures."""
79class MalformedError(DefaultCredentialsError, ValueError):
80 """An exception for malformed data."""
83class InvalidResource(DefaultCredentialsError, ValueError):
84 """An exception for URL error."""
87class InvalidOperation(DefaultCredentialsError, ValueError):
88 """An exception for invalid operation."""
91class InvalidValue(DefaultCredentialsError, ValueError):
92 """Used to wrap general ValueError of python."""
95class InvalidType(DefaultCredentialsError, TypeError):
96 """Used to wrap general TypeError of python."""
99class OSError(DefaultCredentialsError, EnvironmentError):
100 """Used to wrap EnvironmentError(OSError after python3.3)."""