Question: Add Exception Trace to Response Content
Is there a way to add full stack traces to the JSON response content for exceptions? I am using JMS Serializer and have played around with a few different options but I haven't found a reliable way that doesn't rely on the internal classes of FOSRestBundle but also maintains the status code and message mapping that is being performed in \FOS\RestBundle\Serializer\Normalizer\FlattenExceptionHandler.
The cleanest way to do this without changes to FlattenExceptionHandler would be to implement a JMS Serializer post_serializer event, but JMS Serializer doesn't fire the post_serializer event for custom handlers.
One option would be to add a new configuration option for this. Something like:
fos_rest:
exception:
show_trace: "%kernel.debug%"
This would be easy enough to implement in \FOS\RestBundle\Serializer\Normalizer\FlattenExceptionHandler and \FOS\RestBundle\Serializer\Normalizer\FlattenExceptionNormalizer.
Any assistance or thoughts would be greatly appreciated.