diff --git a/README.md b/README.md index 684cb4dd5..588824967 100644 --- a/README.md +++ b/README.md @@ -402,7 +402,7 @@ ExceptionController support Using this custom ExceptionController it is possible to leverage the View layer when building responses for uncaught Exceptions. -The RestBundle view-layer-aware ExceptionController is enabled as follows: +To enable the RestBundle view-layer-aware ExceptionController update the framework section of your config like this: ```yaml # app/config/config.yml @@ -425,6 +425,25 @@ fos_rest: 'Acme\HelloBundle\Exception\MyExceptionWithASafeMessage': true ``` +If you want to display the message from the exception in the content of the response, add the +exception to the messages map as well. If not only the statuscode will be returned. + +If you know what status code you want to return you do not have to add a mapping, you can do +this in your controller: + +```php +validate($slug)) { + throw new HttpException(400, "New comment is not valid."); + } + } +} +``` + See the following example configuration for more details: https://github.com/lsmith77/symfony-standard/blob/techtalk/app/config/config.yml