protected function getJsonReponseFromException(Exception $ex)
    {
        $authorizationChecker = $this->get('security.authorization_checker');
        $logger = $this->get('logger');

        //can we see the debug
        $isDebugAllowed = $authorizationChecker->isGranted('ROLE_VICTOIRE_PAGE_DEBUG') ? true : $this->get('kernel')->isDebug();

        //whatever is the exception, we log it
        $logger->error($ex->getMessage());
        $logger->error($ex->getTraceAsString());

        if ($isDebugAllowed) {
            throw $ex;
        } else {
            //translate the message
            $translator = $this->get('translator');

            //get the translated message
            $message = $translator->trans('error_occured', [], 'victoire');

            $response = new JsonResponse(
                [
                    'success' => false,
                    'message' => $message,
                ]
            );
        }

        return $response;
    }