Errors

class restfly.errors.RestflyException(msg)[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.

class restfly.errors.UnexpectedValueError(msg)[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.

class restfly.errors.APIError(r, retries=None)[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
class restfly.errors.BadRequestError(r, retries=None)[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).

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
class restfly.errors.UnauthorizedError(r, retries=None)[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.

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
class restfly.errors.ForbiddenError(r, retries=None)[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.

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
class restfly.errors.NotFoundError(r, retries=None)[source]

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

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
class restfly.errors.InvalidMethodError(r, retries=None)[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.

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
class restfly.errors.NotAcceptableError(r, retries=None)[source]

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

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
class restfly.errors.ProxyAuthenticationError(r, retries=None)[source]

The client must first authenticate itself with the proxy.

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
class restfly.errors.RequestTimeoutError(r, retries=None)[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.

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
class restfly.errors.RequestConflictError(r, retries=None)[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.

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
class restfly.errors.NoLongerExistsError(r, retries=None)[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.

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
class restfly.errors.LengthRequiredError(r, retries=None)[source]

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

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
class restfly.errors.PreconditionFailedError(r, retries=None)[source]

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

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
class restfly.errors.PayloadTooLargeError(r, retries=None)[source]

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

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
class restfly.errors.URITooLongError(r, retries=None)[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.

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
class restfly.errors.UnsupportedMediaTypeError(r, retries=None)[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.

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
class restfly.errors.RangeNotSatisfiableError(r, retries=None)[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.

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
class restfly.errors.ExpectationFailedError(r, retries=None)[source]

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

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
class restfly.errors.TeapotResponseError(r, retries=None)[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.

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
class restfly.errors.MisdirectRequestError(r, retries=None)[source]

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

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
class restfly.errors.TooEarlyError(r, retries=None)[source]

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

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
class restfly.errors.UpgradeRequiredError(r, retries=None)[source]

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

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
class restfly.errors.PreconditionRequiredError(r, retries=None)[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.

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
class restfly.errors.TooManyRequestsError(r, retries=None)[source]

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

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
class restfly.errors.RequestHeaderFieldsTooLargeError(r, retries=None)[source]

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

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
class restfly.errors.UnavailableForLegalReasonsError(r, retries=None)[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.

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
class restfly.errors.ServerError(r, retries=None)[source]

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

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
class restfly.errors.MethodNotImplementedError(r, retries=None)[source]

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

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
class restfly.errors.BadGatewayError(r, retries=None)[source]

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

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
class restfly.errors.ServiceUnavailableError(r, retries=None)[source]

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

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
class restfly.errors.GatewayTimeoutError(r, retries=None)[source]

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

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
class restfly.errors.NotExtendedError(r, retries=None)[source]

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

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
class restfly.errors.NetworkAuthenticationRequiredError(r, retries=None)[source]

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

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