Exceptions
Exceptions raised by Google API core & clients.
This module provides base classes for all errors raised by libraries based
on
google.api_core
, including both HTTP and gRPC clients.
exception
google.api_core.exceptions.
Aborted
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.Conflict
Exception mapping a
grpc.StatusCode.ABORTED
error.
exception
google.api_core.exceptions.
AlreadyExists
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.Conflict
Exception mapping a
grpc.StatusCode.ALREADY_EXISTS
error.
exception
google.api_core.exceptions.
BadGateway
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.ServerError
Exception mapping a
502
Bad
Gateway
response.
exception
google.api_core.exceptions.
BadRequest
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.ClientError
Exception mapping a
400
Bad
Request
response.
exception
google.api_core.exceptions.
Cancelled
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.ClientError
Exception mapping a
grpc.StatusCode.CANCELLED
error.
exception
google.api_core.exceptions.
ClientError
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.GoogleAPICallError
Base class for all client error (HTTP 4xx) responses.
exception
google.api_core.exceptions.
Conflict
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.ClientError
Exception mapping a
409
Conflict
response.
exception
google.api_core.exceptions.
DataLoss
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.ServerError
Exception mapping a
grpc.StatusCode.DATA_LOSS
error.
exception
google.api_core.exceptions.
DeadlineExceeded
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.GatewayTimeout
Exception mapping a
grpc.StatusCode.DEADLINE_EXCEEDED
error.
exception
google.api_core.exceptions.
DuplicateCredentialArgs
[source]
Bases:
google.api_core.exceptions.GoogleAPIError
Raised when multiple credentials are passed.
exception
google.api_core.exceptions.
FailedPrecondition
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.BadRequest
Exception mapping a
grpc.StatusCode.FAILED_PRECONDITION
error.
exception
google.api_core.exceptions.
Forbidden
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.ClientError
Exception mapping a
403
Forbidden
response.
exception
google.api_core.exceptions.
GatewayTimeout
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.ServerError
Exception mapping a
504
Gateway
Timeout
response.
exception
google.api_core.exceptions.
GoogleAPICallError
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.GoogleAPIError
Base class for exceptions raised by calling API methods.
Parameters
message
(
str
) – The exception message.
errors
(
Sequence
[
Any
]
) – An optional list of error details.
details
(
Sequence
[
Any
]
) – An optional list of objects defined in google.rpc.error_details.
response
(
Union
[
requests.Request
,
grpc.Call
]
) – The response or
gRPC call metadata.
error_info
(
Union
[
error_details_pb2.ErrorInfo
,
None
]
) – An optional object containing error info
(google.rpc.error_details.ErrorInfo).
code
:
Optional
[
int
]
=
None
The HTTP status code associated with this error.
This may be
None
if the exception does not have a direct mapping
to an HTTP error.
See
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
Optional[
int
]
Information contained in google.rpc.status.details.
Reference:
https://github.com/googleapis/googleapis/blob/master/google/rpc/status.proto
https://github.com/googleapis/googleapis/blob/master/google/rpc/error_details.proto
Returns
A list of structured objects from error_details.proto
Return type
Sequence[Any]
An optional string containing a logical grouping to which the “reason” belongs.
Return type
Union[
str
,
None
]
The gRPC status code associated with this
error.
This may be
None
if the exception does not match up to a gRPC error.
Optional[
grpc.StatusCode
]
exception
google.api_core.exceptions.
InternalServerError
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.ServerError
Exception mapping a
500
Internal
Server
Error
response. or a
grpc.StatusCode.INTERNAL
error.
exception
google.api_core.exceptions.
InvalidArgument
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.BadRequest
Exception mapping a
grpc.StatusCode.INVALID_ARGUMENT
error.
exception
google.api_core.exceptions.
LengthRequired
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.ClientError
Exception mapping a
411
Length
Required
response.
exception
google.api_core.exceptions.
MethodNotAllowed
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.ClientError
Exception mapping a
405
Method
Not
Allowed
response.
exception
google.api_core.exceptions.
MethodNotImplemented
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.ServerError
Exception mapping a
501
Not
Implemented
response or a
grpc.StatusCode.UNIMPLEMENTED
error.
exception
google.api_core.exceptions.
MovedPermanently
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.Redirection
Exception mapping a
301
Moved
Permanently
response.
exception
google.api_core.exceptions.
NotFound
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.ClientError
Exception mapping a
404
Not
Found
response or a
grpc.StatusCode.NOT_FOUND
error.
exception
google.api_core.exceptions.
NotModified
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.Redirection
Exception mapping a
304
Not
Modified
response.
exception
google.api_core.exceptions.
OutOfRange
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.BadRequest
Exception mapping a
grpc.StatusCode.OUT_OF_RANGE
error.
exception
google.api_core.exceptions.
PermissionDenied
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.Forbidden
Exception mapping a
grpc.StatusCode.PERMISSION_DENIED
error.
exception
google.api_core.exceptions.
PreconditionFailed
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.ClientError
Exception mapping a
412
Precondition
Failed
response.
exception
google.api_core.exceptions.
Redirection
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.GoogleAPICallError
Base class for for all redirection (HTTP 3xx) responses.
exception
google.api_core.exceptions.
RequestRangeNotSatisfiable
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.ClientError
Exception mapping a
416
Request
Range
Not
Satisfiable
response.
exception
google.api_core.exceptions.
ResourceExhausted
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.TooManyRequests
Exception mapping a
grpc.StatusCode.RESOURCE_EXHAUSTED
error.
exception
google.api_core.exceptions.
ResumeIncomplete
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.Redirection
Exception mapping a
308
Resume
Incomplete
response.
http.client.PERMANENT_REDIRECT
is
308
, but Google
APIs differ in their use of this status code.
exception
google.api_core.exceptions.
RetryError
(
message
,
cause
)
[source]
Bases:
google.api_core.exceptions.GoogleAPIError
Raised when a function has exhausted all of its available retries.
Parameters
message
(
str
) – The exception message.
cause
(
Exception
) – The last exception raised when retrying the
function.
exception
google.api_core.exceptions.
ServerError
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.GoogleAPICallError
Base for 5xx responses.
exception
google.api_core.exceptions.
ServiceUnavailable
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.ServerError
Exception mapping a
503
Service
Unavailable
response or a
grpc.StatusCode.UNAVAILABLE
error.
exception
google.api_core.exceptions.
TemporaryRedirect
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.Redirection
Exception mapping a
307
Temporary
Redirect
response.
exception
google.api_core.exceptions.
TooManyRequests
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.ClientError
Exception mapping a
429
Too
Many
Requests
response.
exception
google.api_core.exceptions.
Unauthenticated
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.Unauthorized
Exception mapping a
grpc.StatusCode.UNAUTHENTICATED
error.
exception
google.api_core.exceptions.
Unauthorized
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.ClientError
Exception mapping a
401
Unauthorized
response.
exception
google.api_core.exceptions.
Unknown
(
message
,
errors
=
()
,
details
=
()
,
response
=
None
,
error_info
=
None
)
[source]
Bases:
google.api_core.exceptions.ServerError
Exception mapping a
grpc.StatusCode.UNKNOWN
error.
google.api_core.exceptions.
exception_class_for_grpc_status
(
status_code
)
[source]
Return the exception class for a specific
grpc.StatusCode
.
Parameters
status_code
(
grpc.StatusCode
) – The gRPC status code.
Returns
the appropriate subclass of
GoogleAPICallError
.
Return type
type()
google.api_core.exceptions.
exception_class_for_http_status
(
status_code
)
[source]
Return the exception class for a specific HTTP status code.
Parameters
status_code
(
int
) – The HTTP status code.
Returns
the appropriate subclass of
GoogleAPICallError
.
Return type
type()
google.api_core.exceptions.
from_grpc_error
(
rpc_exc
)
[source]
Create a
GoogleAPICallError
from a
grpc.RpcError
.
Parameters
rpc_exc
(
grpc.RpcError
) – The gRPC error.
Returns
An instance of the appropriate subclass of
GoogleAPICallError
.
google.api_core.exceptions.
from_grpc_status
(
status_code
,
message
,
**
kwargs
)
[source]
Create a
GoogleAPICallError
from a
grpc.StatusCode
.
Parameters
status_code
(
Union
[
grpc.StatusCode
,
int
]
) – The gRPC status code.
message
(
str
) – The exception message.
kwargs
– Additional arguments passed to the
GoogleAPICallError
constructor.
Returns
An instance of the appropriate subclass of
GoogleAPICallError
.
google.api_core.exceptions.
from_http_response
(
response
)
[source]
Create a
GoogleAPICallError
from a
requests.Response
.
Parameters
response
(
requests.Response
) – The HTTP response.
Returns
An instance of the appropriate subclass of
GoogleAPICallError
, with the message and errors populated
from the response.
google.api_core.exceptions.
from_http_status
(
status_code
,
message
,
**
kwargs
)
[source]
Create a
GoogleAPICallError
from an HTTP status code.
Parameters
status_code
(
int
) – The HTTP status code.
message
(
str
) – The exception message.
kwargs
– Additional arguments passed to the
GoogleAPICallError
constructor.
Returns
An instance of the appropriate subclass of
GoogleAPICallError
.