<commit_before><?php

namespace Opstalent\ApiBundle\Controller;

use Symfony\Bundle\TwigBundle\Controller\ExceptionController as BaseExceptionController;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;

class ExceptionController extends BaseExceptionController
{

    public function __construct()
    {
//        parent::__construct($twig,$debug);
    }

    public function showExceptionAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null)
    {
        return new JsonResponse([
            'success' => false,
            'code'    => $exception->getCode(),
            'message' => $exception->getMessage(),
        ], $this->getExceptionCode($exception));
    }

    /**
     * @param FlattenException $exception
     * @return int
     */
    protected function getExceptionCode(FlattenException $exception) : int
    {
        $code = $exception->getCode();

        return array_key_exists($code, JsonResponse::$statusTexts) ? $code : 500;
    }
}<commit_msg>Exception controller code detecting fix<commit_after><?php

namespace Opstalent\ApiBundle\Controller;

use Symfony\Bundle\TwigBundle\Controller\ExceptionController as BaseExceptionController;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;

class ExceptionController extends BaseExceptionController
{
    public function __construct()
    {
        // DO NOT RUN parent::__construct()
    }

    public function showExceptionAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null)
    {
        $code = $this->getExceptionCode($exception);

        return new JsonResponse([
            'success' => false,
            'code'    => $code,
            'message' => $exception->getMessage(),
        ], $code);
    }

    /**
     * @param FlattenException $exception
     * @return int
     */
    protected function getExceptionCode(FlattenException $exception) : int
    {
        $code = $exception->getCode();
        if (array_key_exists($code, JsonResponse::$statusTexts)) {
            return $code;
        }

        if ($exception->getPrevious() && $exception->getPrevious() instanceof FlattenException) {
            return $this->getExceptionCode($exception->getPrevious());
        }

        return 500;
    }
}
{'fraction_non_alphanumeric': 0.10952564596991901, 'fraction_numerical': 0.0023139220979560356, 'mean_word_length': 3.4115646258503403, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5375702', 'n_tokens_mistral': 673, 'n_tokens_neox': 662, 'n_words': 136}