我在我的网站上使用whoops,现在我试着让它与PDO错误一起工作,在缺少连接到数据库的信息时工作正常,但是当您(例如)键入不存在的表时,它不要显示错误。哎哟要抓住PDO错误?
我已经尝试添加PrettyPageHandler::addDataTable()
到我的错误亨德尔
db.php中
class db {
// just some not important code here...
// Try to get the result from database.
try {
$pdo = DB::getInstance()->db->prepare($sql);
$pdo->execute($execute);
$result = $pdo->fetchAll(PDO::FETCH_ASSOC);
// Return Result
return $result;
}
catch(PDOException $e)
{
PrettyPageHandler::addDataTable(null, $e);
}
}
的index.php
<?php
if(file_exists("plugins/whoops/autoload.php"))
{
require_once 'plugins/whoops/autoload.php';
$whoops = new \Whoops\Run;
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
$whoops->register();
}
require_once db.php';
$db = new db();
但后来我得到一个类 'PrettyPageHandler' 未找到
您是否包含/需要包含PrettyPageHandler类的文件? – flynorc
你有'使用Whoops \ Handler \ PrettyPageHandler;'在你的代码中? –
@JiriHrazdil 2秒我更新了帖子 –