我在我的網站上使用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秒我更新了帖子 –