From 011ba3cc875a7cda06d3f4318a9f40f65e469bc8 Mon Sep 17 00:00:00 2001 From: Tarjei Huse Date: Thu, 8 Sep 2011 11:09:22 +0200 Subject: [PATCH 1/2] Expand description of exceptions --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4259335df..844bd0441 100644 --- a/README.md +++ b/README.md @@ -442,7 +442,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 @@ -465,6 +465,9 @@ 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. + See the following example configuration for more details: https://github.com/lsmith77/symfony-standard/blob/techtalk/app/config/config.yml From 2598c03f368fa8d413537c235fd8c4c279c205d4 Mon Sep 17 00:00:00 2001 From: Tarjei Huse Date: Thu, 8 Sep 2011 11:28:35 +0200 Subject: [PATCH 2/2] Add example of using HttpException instead of ExceptionMap --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 844bd0441..9a0172ca9 100644 --- a/README.md +++ b/README.md @@ -468,6 +468,22 @@ fos_rest: 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