The following exception classes may be raised by Descartes Labs client APIs when an error in a client request is encountered.

descarteslabs.exceptions

Exceptions raised by HTTP clients.

descarteslabs.client.grpc.exceptions

Exceptions raised by gRPC clients.

HTTP Exceptions

Exceptions raised by HTTP clients.

exception AuthError[source]

Bases: descarteslabs.exceptions.ClientError

Authentication error, improperly supplied credentials.

exception BadRequestError[source]

Bases: descarteslabs.exceptions.ClientError

Client request with invalid or incorrect parameters.

status = 400
exception ClientError[source]

Bases: Exception

Base class for all client exceptions.

exception ConflictError[source]

Bases: descarteslabs.exceptions.ClientError

Client request conflicts with existing state.

status = 409
exception GatewayTimeoutError[source]

Bases: descarteslabs.exceptions.ServerError

Timeout from the gateway after failing to route request to destination service.

status = 504
exception NotFoundError[source]

Bases: descarteslabs.exceptions.ClientError

Resource not found.

status = 404
exception OauthError[source]

Bases: descarteslabs.exceptions.AuthError

Authentication error, failure from OAuth authentication service.

exception ProxyAuthenticationRequiredError[source]

Bases: descarteslabs.exceptions.ClientError

Client request needs proxy authentication.

status = 407
exception RateLimitError(message, retry_after=None)[source]

Bases: descarteslabs.exceptions.ClientError

Client request exceeds rate limits.

The retry_after member will contain any time limit returned in the response.

Construct a new instance.

Parameters
  • message (str) – The error message.

  • retry_after (str or None) – An indication of a retry-after timeout specified by the error response.

status = 429
exception RetryWithError[source]

Bases: descarteslabs.exceptions.ClientError

Vector service query request timed out.

status = 449
exception ServerError[source]

Bases: Exception

Server or service failure.

status = 500

gRPC Exceptions

Exceptions raised by gRPC clients.

exception APICallError(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.APIError

Base class for exceptions raised by calling API methods.

Parameters
  • message (str) – The exception message.

  • errors (Sequence[Any]) – An optional list of error details.

  • response (Union[requests.Request, grpc.Call]) – The response or gRPC call metadata.

code = 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

Type

Optional[int]

property errors

Detailed error information.

Returns

A list of additional error details.

Return type

Sequence[Any]

grpc_status_code = None

The gRPC status code associated with this error.

This may be None if the exception does not match up to a gRPC error.

Type

Optional[grpc.StatusCode]

message = None

The exception message.

Type

str

property response

The response or gRPC call metadata.

Type

Optional[Union[requests.Request, grpc.Call]]

exception APIError[source]

Bases: Exception

Base class for all exceptions raised by clients.

exception Aborted(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.Conflict

Exception mapping a grpc.StatusCode.ABORTED error.

grpc_status_code = (10, 'aborted')
exception AlreadyExists(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.Conflict

Exception mapping a grpc.StatusCode.ALREADY_EXISTS error.

grpc_status_code = (6, 'already exists')
exception BadGateway(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.ServerError

Exception mapping a 502 Bad Gateway response.

code = 502
exception BadRequest(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.ClientError

Exception mapping a 400 Bad Request response.

code = 400
exception Cancelled(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.ClientError

Exception mapping a grpc.StatusCode.CANCELLED error.

code = 499
grpc_status_code = (1, 'cancelled')
exception ClientError(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.APICallError

Base class for all client error (HTTP 4xx) responses.

exception Conflict(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.ClientError

Exception mapping a 409 Conflict response.

code = 409
exception DataLoss(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.ServerError

Exception mapping a grpc.StatusCode.DATA_LOSS error.

grpc_status_code = (15, 'data loss')
exception DeadlineExceeded(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.GatewayTimeout

Exception mapping a grpc.StatusCode.DEADLINE_EXCEEDED error.

grpc_status_code = (4, 'deadline exceeded')
exception FailedPrecondition(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.BadRequest

Exception mapping a grpc.StatusCode.FAILED_PRECONDITION error.

grpc_status_code = (9, 'failed precondition')
exception Forbidden(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.ClientError

Exception mapping a 403 Forbidden response.

code = 403
exception GatewayTimeout(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.ServerError

Exception mapping a 504 Gateway Timeout response.

code = 504
exception InternalServerError(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.ServerError

Exception mapping a 500 Internal Server Error response. or a grpc.StatusCode.INTERNAL error.

code = 500
grpc_status_code = (13, 'internal')
exception InvalidArgument(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.BadRequest

Exception mapping a grpc.StatusCode.INVALID_ARGUMENT error.

grpc_status_code = (3, 'invalid argument')
exception LengthRequired(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.ClientError

Exception mapping a 411 Length Required response.

code = 411
exception MethodNotAllowed(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.ClientError

Exception mapping a 405 Method Not Allowed response.

code = 405
exception MethodNotImplemented(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.ServerError

Exception mapping a 501 Not Implemented response or a grpc.StatusCode.UNIMPLEMENTED error.

code = 501
grpc_status_code = (12, 'unimplemented')
exception MovedPermanently(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.Redirection

Exception mapping a 301 Moved Permanently response.

code = 301
exception NotFound(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.ClientError

Exception mapping a 404 Not Found response or a grpc.StatusCode.NOT_FOUND error.

code = 404
grpc_status_code = (5, 'not found')
exception NotModified(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.Redirection

Exception mapping a 304 Not Modified response.

code = 304
exception OutOfRange(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.BadRequest

Exception mapping a grpc.StatusCode.OUT_OF_RANGE error.

grpc_status_code = (11, 'out of range')
exception PermissionDenied(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.Forbidden

Exception mapping a grpc.StatusCode.PERMISSION_DENIED error.

grpc_status_code = (7, 'permission denied')
exception PreconditionFailed(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.ClientError

Exception mapping a 412 Precondition Failed response.

code = 412
exception Redirection(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.APICallError

Base class for for all redirection (HTTP 3xx) responses.

exception RequestRangeNotSatisfiable(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.ClientError

Exception mapping a 416 Request Range Not Satisfiable response.

code = 416
exception ResourceExhausted(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.TooManyRequests

Exception mapping a grpc.StatusCode.RESOURCE_EXHAUSTED error.

grpc_status_code = (8, 'resource exhausted')
exception ResumeIncomplete(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.Redirection

Exception mapping a 308 Resume Incomplete response.

Note

http_client.PERMANENT_REDIRECT is 308, but APIs differ in their use of this status code.

code = 308
exception ServerError(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.APICallError

Base for 5xx responses.

exception ServiceUnavailable(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.ServerError

Exception mapping a 503 Service Unavailable response or a grpc.StatusCode.UNAVAILABLE error.

code = 503
grpc_status_code = (14, 'unavailable')
exception TemporaryRedirect(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.Redirection

Exception mapping a 307 Temporary Redirect response.

code = 307
exception TooManyRequests(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.ClientError

Exception mapping a 429 Too Many Requests response.

code = 429
exception Unauthenticated(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.Unauthorized

Exception mapping a grpc.StatusCode.UNAUTHENTICATED error.

grpc_status_code = (16, 'unauthenticated')
exception Unauthorized(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.ClientError

Exception mapping a 401 Unauthorized response.

code = 401
exception Unknown(message, errors=(), response=None)[source]

Bases: descarteslabs.client.grpc.exceptions.ServerError

Exception mapping a grpc.StatusCode.UNKNOWN error.

grpc_status_code = (2, 'unknown')
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 APICallError.

Return type

type()

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 APICallError.

Return type

type()

from_grpc_error(rpc_exc)[source]

Create a APICallError from a grpc.RpcError.

Parameters

rpc_exc (grpc.RpcError) – The gRPC error.

Returns

An instance of the appropriate subclass of

APICallError.

Return type

APICallError

from_grpc_status(status_code, message, **kwargs)[source]

Create a APICallError from a grpc.StatusCode.

Parameters
  • status_code (grpc.StatusCode) – The gRPC status code.

  • message (str) – The exception message.

  • kwargs – Additional arguments passed to the APICallError constructor.

Returns

An instance of the appropriate subclass of

APICallError.

Return type

APICallError

from_http_response(response)[source]

Create a APICallError from a requests.Response.

Parameters

response (requests.Response) – The HTTP response.

Returns

An instance of the appropriate subclass of

APICallError, with the message and errors populated from the response.

Return type

APICallError

from_http_status(status_code, message, **kwargs)[source]

Create a APICallError from an HTTP status code.

Parameters
  • status_code (int) – The HTTP status code.

  • message (str) – The exception message.

  • kwargs – Additional arguments passed to the APICallError constructor.

Returns

An instance of the appropriate subclass of

APICallError.

Return type

APICallError