codeguy/Slim — pull request #181 by maikg (2011-10-09 16:07:40+00:00)
Title: Add support for 422 HTTP status code

Rails uses 422 (Unprocessable Entity) to communicate errors in the semantics of the posted entity (f.e. when validations fail).

From RFC 4918:

> 11.2. 422 Unprocessable Entity
>
> The 422 (Unprocessable Entity) status code means the server
understands the content type of the request entity (hence a
415(Unsupported Media Type) status code is inappropriate), and the
syntax of the request entity is correct (thus a 400 (Bad Request)
status code is inappropriate) but was unable to process the contained
instructions. For example, this error condition may occur if an XML
request body contains well-formed (i.e., syntactically correct), but
semantically erroneous, XML instructions.

Slim currently throws an exception when trying to set the status code to 422, and as far as I can see there is no workaround as the Status header is overwritten right before sending the headers.