Search code examples
symfonyexceptionsymfony-2.8custom-exceptions

Symfony 2 - In production not return POST Json custom message exception


I'm using Symfony 2.8

I have a POST method root. The return format is json.

app_patient_create:
path: /
methods: [POST]
defaults:
    _controller: App:Patient:create
    _format: json
    _angular_safe: true

In a Listener in this root, i have an exception.

throw new Exception\MaxPointsException();

This is the custom exception :

namespace App\Training\Exception;

class MaxPointsException extends \LogicException
{
    public function __construct()
    {
        parent::__construct('Vous avez atteint le nombre maximal de patients inclus dans votre offre découverte. Pour continuer à profiter du site, veuillez vous abonner');
    }
}

In dev environnement, the message is return :

enter image description here

But not in prod environnement :

enter image description here

Did you know why?


Solution

  • I use an HTTP 409 reponse for recognize my exception.