symfony/symfony — pull request #5312 by ramsey (2012-08-21 22:10:53+00:00)
Title: [HttpKernel] Additional HTTP exceptions

I wanted to continue using exceptions for many other types of HTTP 4xx and 5xx status codes, particularly because I like the notion that I can trap the exception based on the type, rather than inspecting HttpException to see what status code it contains. I've decided to contribute these back to the Symfony HttpKernel component, in case others find them useful.

* Bug fix: no
* Feature addition: yes
* Backwards compatibility break: no
* Symfony2 tests pass: yes
* Fixes the following tickets: -
* Todo: -
* License of the code: MIT
* Documentation PR: n/a

This pull request provides the following new HttpKernel Exceptions:

Exception | Applicable HTTP Status Code
---------------------------------- | ---------------------------------------
BadRequestHttpException | `400 Bad Request`
ConflictHttpException | `409 Conflict`
GoneHttpException | `410 Gone`
InternalServerErrorHttpException | `500 Internal Server Error`
LengthRequiredHttpException | `411 Length Required`
NotAcceptableHttpException | `406 Not Acceptable`
PreconditionFailedHttpException | `412 Precondition Failed`
PreconditionRequiredHttpException | `428 Precondition Required`†
ServiceUnavailableHttpException | `503 Service Unavailable`
TooManyRequestsHttpException | `429 Too Many Requests`†
UnauthorizedHttpException | `401 Unauthorized`
UnsupportedMediaTypeHttpException | `415 Unsupported Media Type`

All the tests have been placed in the FlattenExceptionTest, since that's where the previous status code and method tests for HttpException exceptions are located, but I can move them to a more logical location, if needed.

† These codes have been included from [RFC 6585, Additional HTTP Status Codes](http://tools.ietf.org/html/rfc6585).