libcloud.common.exceptions module

exception libcloud.common.exceptions.BaseHTTPError(code, message, headers=None)[source]

Bases: Exception

The base exception class for all HTTP related exceptions.

exception libcloud.common.exceptions.RateLimitReachedError(*args, **kwargs)[source]

Bases: BaseHTTPError

HTTP 429 - Rate limit: you’ve sent too many requests for this time period.

code = 429
message = '429 Rate limit exceeded'
libcloud.common.exceptions.exception_from_message(code, message, headers=None)[source]

Return an instance of BaseHTTPException or subclass based on response code.

If headers include Retry-After, RFC 2616 says that its value may be one of two formats: HTTP-date or delta-seconds, for example:

Retry-After: Fri, 31 Dec 1999 23:59:59 GMT Retry-After: 120

If Retry-After comes in HTTP-date, it’ll be translated to a positive delta-seconds value when passing it to the exception constructor.

Also, RFC 2616 says that Retry-After isn’t just only applicable to 429 HTTP status, but also to other responses, like 503 and 3xx.

raise exception_from_message(code=self.status,

message=self.parse_error(), headers=self.headers)