Good afternoon, I have used in several projects Silex Skeleton and had not realized that they all exception code does not return properly, use the following code
$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(
'errors/'.$code.'.html',
'errors/'.substr($code, 0, 2).'x.html',
'errors/'.substr($code, 0, 1).'xx.html',
'errors/default.html',
);
return new Response($app['twig']->resolveTemplate($templates)->render(array('code' => $code)), $code);
});
And when printing the variable $ code gives me the following:
GET /demos/ HTTP/1.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Encoding: gzip, deflate, sdch Accept-Language: es,en;q=0.8 Cache-Control: max-age=0 Connection: keep-alive Cookie: _ga=GA1.2.33103823.1399416189; _CRM=0nonn2h02c4mbhgbdvjhs8d852 Host: crmtyc.domainame.com User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.104 Safari/537.36
This on local and production servers.
I would appreciate any comments or suggestions.