Errors

exception RestflyException(msg, **kwargs)[source]

Base exception class that sets up logging and handles some basic scaffolding for all other exception classes. This exception should never be directly seen.

exception UnexpectedValueError(msg, **kwargs)[source]

An unexpected value error is thrown whenever the value specified for a parameter is outside the bounds of what is expected. For example, if the parameter a is expected to have a value of 1, 2, or 3, and it is instead passed a value of 0, then it is an unexpected value, and this Exception should be thrown by the package.

exception RequiredParameterError(msg, **kwargs)[source]

A Required Parameter error is thrown whenever the value specified for a parameter is required to have a value other than None.

exception APIError(resp, **kwargs)[source]

The APIError Exception is a generic Exception for handling responses from the API that aren’t whats expected. The APIError Exception itself attempts to provide the developer with enough information around the response to ascertain what went wrong.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception BadRequestError(resp, **kwargs)[source]

The server cannot or will not process the request due to an apparent client error (e.g., malformed request syntax, size too large, invalid request message framing, or deceptive request routing).

Typically associated with a 400 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception UnauthorizedError(resp, **kwargs)[source]

Similar to 403 Forbidden, but specifically for use when authentication is required and has failed or has not yet been provided. The response must include a WWW-Authenticate header field containing a challenge applicable to the requested resource. See Basic access authentication and Digest access authentication. 401 semantically means “unauthenticated”, i.e. the user does not have the necessary credentials.

Typically associated with a 401 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception ForbiddenError(resp, **kwargs)[source]

The request was valid, but the server is refusing action. The user might not have the necessary permissions for a resource, or may need an account of some sort.

Typically associated with a 403 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception NotFoundError(resp, **kwargs)[source]

The requested resource could not be found but may be available in the future. Subsequent requests by the client are permissible.

Typically associated with a 404 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception InvalidMethodError(resp, **kwargs)[source]

A request method is not supported for the requested resource; for example, a GET request on a form that requires data to be presented via POST, or a PUT request on a read-only resource.

Typically associated with a 405 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception NotAcceptableError(resp, **kwargs)[source]

The requested resource is only capable of generating content not acceptable according to the Accept headers sent in the request.

Typically associated with a 406 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception ProxyAuthenticationError(resp, **kwargs)[source]

The client must first authenticate itself with the proxy.

Typically associated with a 407 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception RequestTimeoutError(resp, **kwargs)[source]

The client did not produce a request within the time that the server was prepared to wait. The client MAY repeat the request without modifications at any later time.

Typically associated with a 408 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception RequestConflictError(resp, **kwargs)[source]

Indicates that the request could not be processed because of conflict in the current state of the resource, such as an edit conflict between multiple simultaneous updates.

Typically associated with a 409 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception NoLongerExistsError(resp, **kwargs)[source]

Indicates that the resource requested is no longer available and will not be available again. This should be used when a resource has been intentionally removed and the resource should be purged. Upon receiving a 410 status code, the client should not request the resource in the future. Clients such as search engines should remove the resource from their indices. Most use cases do not require clients and search engines to purge the resource, and a “404 Not Found” may be used instead.

Typically associated with a 410 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception LengthRequiredError(resp, **kwargs)[source]

The request did not specify the length of its content, which is required by the requested resource.

Typically associated with a 411 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception PreconditionFailedError(resp, **kwargs)[source]

The server does not meet one of the preconditions that the requester put on the request.

Typically associated with a 412 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception PayloadTooLargeError(resp, **kwargs)[source]

The request is larger than the server is willing or able to process.

Typically associated with a 413 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception URITooLongError(resp, **kwargs)[source]

The URI provided was too long for the server to process. Often the result of too much data being encoded as a query-string of a GET request, in which case it should be converted to a POST request.

Typically associated with a 414 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception UnsupportedMediaTypeError(resp, **kwargs)[source]

The request entity has a media type which the server or resource does not support. For example, the client uploads an image as image/svg+xml, but the server requires that images use a different format.

Typically associated with a 415 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception RangeNotSatisfiableError(resp, **kwargs)[source]

The client has asked for a portion of the file (byte serving), but the server cannot supply that portion. For example, if the client asked for a part of the file that lies beyond the end of the file.

Typically associated with a 416 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception ExpectationFailedError(resp, **kwargs)[source]

The server cannot meet the requirements of the Expect request-header field.

Typically associated with a 417 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception TeapotResponseError(resp, **kwargs)[source]

This code was defined in 1998 as one of the traditional IETF April Fools’ jokes, in RFC 2324, Hyper Text Coffee Pot Control Protocol, and is not expected to be implemented by actual HTTP servers. The RFC specifies this code should be returned by teapots requested to brew coffee.

Typically associated with a 418 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception MisdirectRequestError(resp, **kwargs)[source]

The request was directed at a server that is not able to produce a response

Typically associated with a 421 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception InvalidContentError(resp, **kwargs)[source]

The request contained content that did not match the expected schema or was otherwise invalid in some way.

Typically associated with a 422 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

requests.Response

exception TooEarlyError(resp, **kwargs)[source]

Indicates that the server is unwilling to risk processing a request that might be replayed.

Typically associated with a 425 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception UpgradeRequiredError(resp, **kwargs)[source]

The client should switch to a different protocol such as TLS/1.0, given in the Upgrade header field.

Typically associated with a 426 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception PreconditionRequiredError(resp, **kwargs)[source]

The origin server requires the request to be conditional. Intended to prevent the ‘lost update’ problem, where a client GETs a resource’s state, modifies it, and PUTs it back to the server, when meanwhile a third party has modified the state on the server, leading to a conflict.

Typically associated with a 428 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception TooManyRequestsError(resp, **kwargs)[source]

The user has sent too many requests in a given amount of time. Intended for use with rate-limiting schemes.

Typically associated with a 429 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception RequestHeaderFieldsTooLargeError(resp, **kwargs)[source]

The server is unwilling to process the request because either an individual header field, or all the header fields collectively, are too large.

Typically associated with a 431 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception UnavailableForLegalReasonsError(resp, **kwargs)[source]

A server operator has received a legal demand to deny access to a resource or to a set of resources that includes the requested resource.

Typically associated with a 451 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception ServerError(resp, **kwargs)[source]

A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.

Typically associated with a 500 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception MethodNotImplementedError(resp, **kwargs)[source]

The server either does not recognize the request method, or it lacks the ability to fulfil the request. Usually this implies future availability.

Typically associated with a 501 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception BadGatewayError(resp, **kwargs)[source]

The server was acting as a gateway or proxy and received an invalid response from the upstream server.

Typically associated with a 502 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception ServiceUnavailableError(resp, **kwargs)[source]

The server cannot handle the request (because it is overloaded or down for maintenance). Generally, this is a temporary state.

Typically associated with a 503 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception GatewayTimeoutError(resp, **kwargs)[source]

The server was acting as a gateway or proxy and did not receive a timely response from the upstream server.

Typically associated with a 504 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception NotExtendedError(resp, **kwargs)[source]

Further extensions to the request are required for the server to fulfil it.

Typically associated with a 510 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response

exception NetworkAuthenticationRequiredError(resp, **kwargs)[source]

The client needs to authenticate to gain network access. Intended for use by intercepting proxies used to control access to the network

Typically associated with a 511 Status code.

code

The HTTP response code from the offending response.

Type:

int

response

This is the Response object that had caused the Exception to fire.

Type:

request.Response