<commit_before><?php

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

use MyApp\Controller;

//Request::setTrustedProxies(array('127.0.0.1'));

$app->error(function (\Exception $e, $code) use ($app) {
    if ($app['debug']) {
        return;
    }

    // 404.html, or 40x.html, or 4xx.html, or error.html
    $templates = array(
        'error/'.$code.'.html.twig',
        'error/'.substr($code, 0, 2).'x.html.twig',
        'error/'.substr($code, 0, 1).'xx.html.twig',
        'error/default.html.twig',
    );

    return new Response($app['twig']->resolveTemplate($templates)->render(array('code' => $code)), $code);
});
<commit_msg>Fixed routing error pages bug<commit_after><?php

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception;

use MyApp\Controller;

//Request::setTrustedProxies(array('127.0.0.1'));

$app->error(function (\Exception $e, Request $request, $code) use ($app) {
    if ($app['debug']) {
        return;
    }

    // 404.html, or 40x.html, or 4xx.html, or error.html
    $templates = array(
        'error/'.$code.'.html.twig',
        'error/'.substr($code, 0, 2).'x.html.twig',
        'error/'.substr($code, 0, 1).'xx.html.twig',
        'error/default.html.twig',
    );

    return new Response($app['twig']->resolveTemplate($templates)->render(array('code' => $code)), $code);
});

{'fraction_non_alphanumeric': 0.188504326328801, 'fraction_numerical': 0.019777503090234856, 'mean_word_length': 3.7339181286549707, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4893137', 'n_tokens_mistral': 566, 'n_tokens_neox': 540, 'n_words': 92}