I used to configure the FOSRestBundle 1.7 exception wrapper handler like it's described in the documentation : http://symfony.com/doc/1.7/bundles/FOSRestBundle/4-exception-controller-support.html I'm doing this in order to display Exception with my own format. Example :
app/config/config.yml :
fos_rest:
view:
exception_handler: AppBundle\Handler\ExceptionWrapperHandler
src/AppBundle/Handler/ExceptionWrapperHandler.php :
namespace AppBundle\Handler;
use FOS\RestBundle\View\ExceptionWrapperHandlerInterface;
class ExceptionWrapperHandler implements ExceptionWrapperHandlerInterface
{
public function wrap($data)
{
$exception = $data['exception'];
return array(
'code' => $exception->getCode(),
'message' => $exception->getMessage()
);
}
}
But when I switched to FOSRestBundle 2.0 version it's not as easy and if I understand right, they advice to use the JMS Serializer handlers. I did not find how to configure it. Can someone please help me on this problem ?