Merge "Add MethodNotAllowed and Conflict exception classes"

This commit is contained in:
Jenkins 2013-05-29 16:39:18 +00:00 committed by Gerrit Code Review
commit c6b913cbc7

View File

@ -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):