我的app/start/global.php
文件中包含以下代码:
App::error(function(\PDOException $exception)
{
return Response::view('errors.db',array(),503);
});
如果我关闭我的数据库并在我的登录页面上运行它,我会得到正确的响应。但是,一旦登录,如果我关闭数据库,我在页面刷新时收到以下错误:
Error in exception handler: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)
以上内容显示在白页上。只有当我对代码发表评论时,才会得到laravel堆栈跟踪:
PDOException
SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)
我也尝试过把它filters.php
文件无效:
App::before(function($request, $response)
{
App::error(function(\PDOException $e, $code)
{
Log::error( 'FATAL DATABASE ERROR: ' . $code . ' = ' . $e->getMessage() );
return Response::view('error.down',array(),503);
}); // end of App::error
});