Browse files

Merge pull request #125 from tarjei/readme

Add more info about the exception handler to the Readme
  • Loading branch information...
2 parents 1ea5450 + 2598c03 commit c6f504d0b5d751fd39043c1f416f3d23f434c794 @lsmith77 lsmith77 committed Sep 8, 2011
Showing with 20 additions and 1 deletion.
  1. +20 −1
@@ -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:
# 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:
+class UsersController extends Controller
+ public function postUserCommentsAction($slug)
+ {
+ if (!$this->validate($slug)) {
+ throw new HttpException(400, "New comment is not valid.");
+ }
+ }
See the following example configuration for more details:

0 comments on commit c6f504d

Please sign in to comment.