Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# Copyright 2010 Jacob Kaplan-Moss # Copyright 2011 Nebula, Inc. Exception definitions. """
"""This form of authentication does not support looking up endpoints from an existing token."""
"""Could not find Service or Region in Service Catalog."""
""" The service catalog is empty. """
"""Unable to find unique resource"""
""" The base exception class for all exceptions this library raises. """
return "%s (HTTP %s)" % (self.message, self.code)
""" HTTP 400 - Bad request: you sent some malformed data. """
""" HTTP 401 - Unauthorized: bad credentials. """
""" HTTP 403 - Forbidden: your credentials don't give you access to this resource. """
""" HTTP 404 - Not found """
""" HTTP 405 - Method not allowed """
""" HTTP 409 - Conflict """
""" HTTP 413 - Over limit: you're over the API limits for this time period. """
# NotImplemented is a python keyword. """ HTTP 501 - Not Implemented: the server does not support this operation. """
""" HTTP 503 - Service Unavailable: The server is currently unavailable. """
# In Python 2.4 Exception is old-style and thus doesn't have a __subclasses__() # so we can do this: # _code_map = dict((c.http_status, c) # for c in ClientException.__subclasses__()) # # Instead, we have to hardcode it: Unauthorized, Forbidden, NotFound, MethodNotAllowed, Conflict, OverLimit, HTTPNotImplemented, ServiceUnavailable])
""" Return an instance of an ClientException or subclass based on an requests response.
Usage::
resp = requests.request(...) if resp.status_code != 200: raise exception_from_response(resp, resp.text) """ else: # If we didn't get back a properly formed error message we # probably couldn't communicate with Keystone at all. else: return cls(code=response.status_code) |