diff options
author | Brian Waldon <bcwaldon@gmail.com> | 2013-05-26 08:14:30 -0700 |
---|---|---|
committer | Brian Waldon <bcwaldon@gmail.com> | 2013-05-26 08:14:32 -0700 |
commit | f2559c4c39af60d8704b813ae0e8effa427a73a0 (patch) | |
tree | c609388642a3d4874d71c6708a75c22f2593c95c /novaclient/exceptions.py | |
parent | 1a0b7b0a649657e2662e62f17322f61e8d7e9ed3 (diff) | |
download | python-novaclient-f2559c4c39af60d8704b813ae0e8effa427a73a0.tar.gz |
Add MethodNotAllowed and Conflict exception classes
It is expected to recieve a 405 or a 409 from Nova, but novaclient presents
them as a generic ClientException. This patch adds MethodNotAllowed
and Conflict classes to represent these HTTP responses.
Change-Id: If89cee04ebd74daaa28ea30b5c57cdc63edc1551
Diffstat (limited to 'novaclient/exceptions.py')
-rw-r--r-- | novaclient/exceptions.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/novaclient/exceptions.py b/novaclient/exceptions.py index b331c3c0..afea9332 100644 --- a/novaclient/exceptions.py +++ b/novaclient/exceptions.py @@ -116,6 +116,22 @@ class NotFound(ClientException): message = "Not found" +class MethodNotAllowed(ClientException): + """ + HTTP 405 - Method Not Allowed + """ + http_status = 405 + message = "Method Not Allowed" + + +class Conflict(ClientException): + """ + 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. @@ -147,8 +163,9 @@ 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]) +_error_classes = [BadRequest, Unauthorized, Forbidden, NotFound, + MethodNotAllowed, Conflict, OverLimit, HTTPNotImplemented] +_code_map = dict((c.http_status, c) for c in _error_classes) def from_response(response, body, url, method=None): |