【发布时间】:2017-11-09 14:11:18
【问题描述】:
我的代码生成 ssse 以下错误:
致命错误:未捕获的类型错误:参数 1 传递给 CI_Exceptions::show_exception() 必须是 Exception 的一个实例, 给定的错误实例,调用 C:\xampp\htdocs\gog\lib\core\Common.php 在第 662 行并在 C:\xampp\htdocs\gog\lib\core\Exceptions.php:190 堆栈跟踪:#0 C:\xampp\htdocs\gog\lib\core\Common.php(662): CI_Exceptions->show_exception(Object(Error)) #1 [内部函数]: _exception_handler(Object(Error)) #2 {main} 在第 190 行的 C:\xampp\htdocs\gog\lib\core\Exceptions.php 中抛出
描述的代码行如下:
function _exception_handler(Throwable $exception)
{
$_error =& load_class('Exceptions', 'core');
$_error->log_exception('error', 'Exception: '.$exception->getMessage(), $exception->getFile(), $exception->getLine());
// Should we display the error?
if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors')))
{
$_error->show_exception($exception); //line 662
}
exit(1); // EXIT_ERROR
}
public function show_exception(Exception $exception) //line 190
{
$templates_path = config_item('error_views_path');
if (empty($templates_path))
{
$templates_path = VIEWPATH.'errors'.DIRECTORY_SEPARATOR;
}
$message = $exception->getMessage();
if (empty($message))
{
$message = '(null)';
}
if (is_cli())
{
$templates_path .= 'cli'.DIRECTORY_SEPARATOR;
}
else
{
set_status_header(500);
$templates_path .= 'html'.DIRECTORY_SEPARATOR;
}
if (ob_get_level() > $this->ob_level + 1)
{
ob_end_flush();
}
ob_start();
include($templates_path.'error_exception.php');
$buffer = ob_get_contents();
ob_end_clean();
echo $buffer;
}
谁能指出我的问题?
【问题讨论】:
-
$exception变量不是Exception的实例(看到你的声明,它是Throwable的实例
标签: php codeigniter exception exception-handling