TP5自定义全局异常处理,重新handle的render方法之后出现如下错误:
( ! ) Fatal error: Uncaught think\exception\ErrorException: Declaration of app\lib\exception\ExceptionHandler::render(think\Exception $ex) should be compatible with think\exception\Handle::render(Exception $e) in /users/jackie/WWW/carpic/server/application/lib/exception/ExceptionHandler.php on line 10
( ! ) think\exception\ErrorException: Declaration of app\lib\exception\ExceptionHandler::render(think\Exception $ex) should be compatible with think\exception\Handle::render(Exception $e) in /users/jackie/WWW/carpic/server/application/lib/exception/ExceptionHandler.php on line 10
Call Stack
# Time Memory Function Location
1 0.0698 1920984 think\Error::appException( ) .../Error.php:0
2 0.0698 1920984 think\Error::getExceptionHandler( ) .../Error.php:43
3 0.0698 1921008 class_exists ( ) .../Error.php:109
4 0.0698 1921072 spl_autoload_call ( ) .../Error.php:109
5 0.0698 1921136 think\Loader::autoload( ) .../Error.php:109
6 0.0698 1921280 think\__include_file( ) .../Loader.php:58
7 0.0701 1923232 include( '/users/jackie/WWW/carpic/server/application/lib/exception/ExceptionHandler.php' ) .../Loader.php:562
8 0.0706 1961984 think\Error::appError( ) .../ExceptionHandler.php:10
"~~~~~"
测试错误信息能正常输出,但是出现致命错误提示;然后看了下handle下的render方法里(Exception $e)用的是use Exception;而我用的是 use think\Exception;
将use think\exception 改为 use Exception,改正后错误小时,以此记录。