title: FOSRestBundle configuration of exceptions messages in prod environment
body: <p>I'm struggling with a problem linked to the FOSRestBundle (version 0.13.*)</p>
  
  <p>I have some REST api that throws some exceptions, nothing unusual I guess. But, despite the specific configuration I made to allow exceptions messages to be formatted in the response even in production (following the documentation I found here : <a href="https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Resources/doc/4-exception-controller-support.md" rel="noreferrer">https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Resources/doc/4-exception-controller-support.md</a>), the JSON response stays desperately empty...</p>
  
  <p>Example below:</p>
  
  <pre><code>http://host/app_dev.php/api/postcode/search?postcode=  
  </code></pre>
  
  <p>results in:</p>
  
  <pre><code>HTTP 400: {"status":"error","status_code":400,"status_text":"Bad Request","current_content":"","message":"You must provide a postcode"}
  </code></pre>
  
  <p>BUT</p>
  
  <pre><code>http://host/api/postcode/search?postcode=
  </code></pre>
  
  <p>results in:</p>
  
  <pre><code>HTTP 400: []
  </code></pre>
  
  <p>My API controller looks like this:</p>
  
  <pre><code>/**
   * Search post codes
   *
   * @param Request   $request   Request
   * @param Promotion $promotion Promotion
   *
   * @Rest\View()
   *
   * @throws BadRequestHttpException
   * @return array
   */
  public function searchAction(Request $request, Promotion $promotion)
  {
      // Get post code
      $postCode = $request-&gt;query-&gt;get('postcode');
      if (!$postCode) {
          throw new BadRequestHttpException('You must provide a postcode');
      }
  
      // SOME LOGIC HERE TO GET DATA
  
      return $data;
  }
  </code></pre>
  
  <p>and the fos_rest configuration looks like this:</p>
  
  <pre><code>fos_rest:
      routing_loader:
          default_format: json
      view:
          mime_types:
              json: ['application/json; charset=UTF-8']
          formats:
              json: true
          view_response_listener: force
      format_listener: false
      access_denied_listener:
          json: true
      body_listener: true
      exception:
          messages:
              Symfony\Component\HttpKernel\Exception\BadRequestHttpException: true
  </code></pre>
  
  <p>As I understood it, the fos_rest.exception.messages configuration array should list the exceptions for which I want a serialization of the error message even in production. As you can see in the code of the controller, this response contains a translated error message that will be displayed to the client. Why is this configuration ignored?
  I can say for sure that the configuration is properly loaded even in prod environment, because if I mispell the class name in the conf, it fails with a "Could not load class" exception.</p>
  
  <p>What am I missing? Thanks in advance for any hint you could give me...</p>