我对slim框架很陌生,并且很难在Slim中设置异常处理,我的要求是在代码中发生意外事件时重定向到错误页面。
试过这段代码
$smartView= new \Slim\Views\Smarty();
$app = new \Slim\Slim(array(
'debug' => false,
'view' => $smartView,
'templates.path' => '../templates/',
));
$app->error(function ( Exception $e ) use ($app) {
echo "my exception print here : " . $e;
});在我的index.php文件中,但苗条仍然调用它的默认异常处理程序。
这是我的路由器呼叫
$app->get('/game', function () use ($app) {
try{
$facebook = new Facebook(array(
'appId' => appid,
'secret' =>appsecret,
'cookie' => true,
'allowSignedRequest' => true
));
$oStuff = new models\User ();
$oStuff->fbLogin($facebook); // To get User details and game select
}
catch (\Exception $e) {
//echo 'Caught exception: ', $e->getMessage(), "\n";
echo $e;
echo "catch exception";
}
});这是我的函数有一些错误
public function fbLogin($facebook)
{
$app = \Slim\Slim::getInstance();
$user = $facebook->getUser() // here is syntax error so i need to get it in my exception
}请帮我解决这个问题,谢谢
发布于 2015-04-14 08:41:32
https://stackoverflow.com/questions/21323578
复制相似问题