summaryrefslogtreecommitdiff
path: root/openstackclient/common/exceptions.py
diff options
context:
space:
mode:
authorJosh Kearney <josh@jk0.org>2013-01-31 13:31:41 -0600
committerJosh Kearney <josh@jk0.org>2013-01-31 13:31:41 -0600
commitb26cb5bf683e7f4f03d9704524a188b76ac5e9b9 (patch)
treef059ddb3b7e15f50d722cf1fbd2b0eaf8242b1a4 /openstackclient/common/exceptions.py
parentaa4f12aec1d13d02df2ecc2710d85ebd90d6dfe7 (diff)
downloadpython-openstackclient-b26cb5bf683e7f4f03d9704524a188b76ac5e9b9.tar.gz
Upgraded to PEP8 1.3.3 to stay aligned with Nova, etc.
Made all the necessary changes to pass new PEP8 standards. Also cleaned up docstrings to conform to the HACKING stanards. Change-Id: Ib8df3030da7a7885655689ab5da0717748c9edbe
Diffstat (limited to 'openstackclient/common/exceptions.py')
-rw-r--r--openstackclient/common/exceptions.py57
1 files changed, 20 insertions, 37 deletions
diff --git a/openstackclient/common/exceptions.py b/openstackclient/common/exceptions.py
index 9dfb4bc7..ab043db0 100644
--- a/openstackclient/common/exceptions.py
+++ b/openstackclient/common/exceptions.py
@@ -13,9 +13,7 @@
# under the License.
#
-"""
-Exception definitions.
-"""
+"""Exception definitions."""
class CommandError(Exception):
@@ -27,8 +25,7 @@ class AuthorizationFailure(Exception):
class NoTokenLookupException(Exception):
- """This form of authentication does not support looking up
- endpoints from an existing token."""
+ """This does not support looking up endpoints from an existing token."""
pass
@@ -38,15 +35,12 @@ class EndpointNotFound(Exception):
class UnsupportedVersion(Exception):
- """Indicates that the user is trying to use an unsupported
- version of the API"""
+ """The user is trying to use an unsupported version of the API"""
pass
class ClientException(Exception):
- """
- The base exception class for all exceptions this library raises.
- """
+ """The base exception class for all exceptions this library raises."""
def __init__(self, code, message=None, details=None):
self.code = code
self.message = message or self.__class__.message
@@ -57,59 +51,44 @@ class ClientException(Exception):
class BadRequest(ClientException):
- """
- HTTP 400 - Bad request: you sent some malformed data.
- """
+ """HTTP 400 - Bad request: you sent some malformed data."""
http_status = 400
message = "Bad request"
class Unauthorized(ClientException):
- """
- HTTP 401 - Unauthorized: bad credentials.
- """
+ """HTTP 401 - Unauthorized: bad credentials."""
http_status = 401
message = "Unauthorized"
class Forbidden(ClientException):
- """
- HTTP 403 - Forbidden: your credentials don't give you access to this
- resource.
- """
+ """HTTP 403 - Forbidden: not authorized to access to this resource."""
http_status = 403
message = "Forbidden"
class NotFound(ClientException):
- """
- HTTP 404 - Not found
- """
+ """HTTP 404 - Not found"""
http_status = 404
message = "Not found"
class Conflict(ClientException):
- """
- HTTP 409 - Conflict
- """
+ """HTTP 409 - Conflict"""
http_status = 409
message = "Conflict"
class OverLimit(ClientException):
- """
- HTTP 413 - Over limit: you're over the API limits for this time period.
- """
+ """HTTP 413 - Over limit: reached the API limits for this time period."""
http_status = 413
message = "Over limit"
# NotImplemented is a python keyword.
class HTTPNotImplemented(ClientException):
- """
- HTTP 501 - Not Implemented: the server does not support this operation.
- """
+ """HTTP 501 - Not Implemented: server does not support this operation."""
http_status = 501
message = "Not Implemented"
@@ -120,14 +99,18 @@ class HTTPNotImplemented(ClientException):
# for c in ClientException.__subclasses__())
#
# Instead, we have to hardcode it:
-_code_map = dict((c.http_status, c) for c in [BadRequest, Unauthorized,
- Forbidden, NotFound, OverLimit, HTTPNotImplemented])
+_code_map = dict((c.http_status, c) for c in [
+ BadRequest,
+ Unauthorized,
+ Forbidden,
+ NotFound,
+ OverLimit,
+ HTTPNotImplemented
+])
def from_response(response, body):
- """
- Return an instance of a ClientException or subclass
- based on an httplib2 response.
+ """Return an instance of a ClientException based on an httplib2 response.
Usage::