dtmsaqtly798322992 2015-04-01 23:47
浏览 35

错误处理程序中的变量$ code在silex中无法正常工作

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 flink cdc无法实时同步mysql数据
    • ¥100 有人会搭建GPT-J-6B框架吗?有偿
    • ¥15 求差集那个函数有问题,有无佬可以解决
    • ¥15 【提问】基于Invest的水源涵养
    • ¥20 微信网友居然可以通过vx号找到我绑的手机号
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名