Bundle/WidgetBundle/Controller/WidgetController.php
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;
    }
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;
    }
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 ; }
Get the json response by the exception and the current user.

@param Exception $ex

@throws Exception

@return JsonResponse
Get the json response by the exception and the current user .