Repository: falconry/falcon

Issue:
Adding HTTP_422, Unprocessable Entity
I guess we need such response support.

Discussion:

Patch:
diff --git a/doc/api/errors.rst b/doc/api/errors.rst
index 26a5960..6cabdfa 100644
--- a/doc/api/errors.rst
+++ b/doc/api/errors.rst
@@ -36,5 +36,5 @@ Predefined Errors
         HTTPBadRequest, HTTPUnauthorized, HTTPForbidden, HTTPNotFound,
         HTTPMethodNotAllowed, HTTPNotAcceptable, HTTPConflict,
         HTTPLengthRequired, HTTPPreconditionFailed, HTTPUnsupportedMediaType,
-        HTTPRangeNotSatisfiable, HTTPInternalServerError, HTTPBadGateway,
-        HTTPServiceUnavailable
+        HTTPRangeNotSatisfiable, HTTPUnprocessableEntity, HTTPInternalServerError,
+        HTTPBadGateway, HTTPServiceUnavailable
diff --git a/doc/api/status.rst b/doc/api/status.rst
index 9e72add..0aa6c68 100644
--- a/doc/api/status.rst
+++ b/doc/api/status.rst
@@ -95,6 +95,7 @@ string objects that must be created when preparing responses.
     HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = HTTP_416
     HTTP_EXPECTATION_FAILED = HTTP_417
     HTTP_IM_A_TEAPOT = HTTP_418
+    HTTP_UNPROCESSABLE_ENTITY = HTTP_422
     HTTP_UPGRADE_REQUIRED = HTTP_426
     HTTP_PRECONDITION_REQUIRED = HTTP_428
     HTTP_TOO_MANY_REQUESTS = HTTP_429
@@ -119,6 +120,7 @@ string objects that must be created when preparing responses.
     HTTP_416 = '416 Range Not Satisfiable'
     HTTP_417 = '417 Expectation Failed'
     HTTP_418 = "418 I'm a teapot"
+    HTTP_422 = "422 Unprocessable Entity"
     HTTP_426 = '426 Upgrade Required'
     HTTP_428 = '428 Precondition Required'
     HTTP_429 = '429 Too Many Requests'
diff --git a/falcon/errors.py b/falcon/errors.py
index 49f2747..7f75b3e 100644
--- a/falcon/errors.py
+++ b/falcon/errors.py
@@ -306,6 +306,24 @@ class HTTPRangeNotSatisfiable(NoRepresentation, HTTPError):
                                                       headers=headers)
 
 
+class HTTPUnprocessableEntity(HTTPError):
+    """422 Unprocessable Entity.
+
+    The request was well-formed but was unable to be followed due to semantic
+    errors. See also: http://www.ietf.org/rfc/rfc4918.
+
+    Args:
+        title (str): Error title (e.g., 'Missing title field').
+        description (str): Human-friendly description of the error, along with
+            a helpful suggestion or two.
+        kwargs (optional): Same as for ``HTTPError``.
+    """
+
+    def __init__(self, title, description, **kwargs):
+        super(HTTPUnprocessableEntity, self).__init__(status.HTTP_422, title,
+                                                      description, **kwargs)
+
+
 class HTTPInternalServerError(HTTPError):
     """500 Internal Server Error.
 
diff --git a/falcon/status_codes.py b/falcon/status_codes.py
index f0c87a4..c27c602 100644
--- a/falcon/status_codes.py
+++ b/falcon/status_codes.py
@@ -90,6 +90,8 @@ HTTP_417 = '417 Expectation Failed'
 HTTP_EXPECTATION_FAILED = HTTP_417
 HTTP_418 = "418 I'm a teapot"
 HTTP_IM_A_TEAPOT = HTTP_418
+HTTP_422 = "422 Unprocessable Entity"
+HTTP_UNPROCESSABLE_ENTITY = HTTP_422
 HTTP_426 = '426 Upgrade Required'
 HTTP_UPGRADE_REQUIRED = HTTP_426
 HTTP_428 = '428 Precondition Required'


Test patch:
diff --git a/tests/test_httperror.py b/tests/test_httperror.py
index 1a99ccb..e48d4b0 100644
--- a/tests/test_httperror.py
+++ b/tests/test_httperror.py
@@ -676,5 +676,6 @@ class TestHTTPError(testing.TestBase):
         self._misc_test(falcon.HTTPPreconditionFailed, falcon.HTTP_412)
         self._misc_test(falcon.HTTPUnsupportedMediaType, falcon.HTTP_415,
                         needs_title=False)
+        self._misc_test(falcon.HTTPUnprocessableEntity, falcon.HTTP_422)
         self._misc_test(falcon.HTTPInternalServerError, falcon.HTTP_500)
         self._misc_test(falcon.HTTPBadGateway, falcon.HTTP_502)