修正错误

This commit is contained in:
thinkphp
2016-02-01 09:11:32 +08:00
parent 8130fbd0f6
commit 8f2055f72e

View File

@@ -13,7 +13,6 @@ namespace think;
use think\Exception;
use think\exception\ErrorException;
use think\exception\NotFoundException;
class Error
{
@@ -40,7 +39,7 @@ class Error
public static function appException(\Exception $exception)
{
/* 非API模式下的部署模式跳转到指定的 Error Page */
if(!(APP_DEBUG || IS_API)){
if (!(APP_DEBUG || IS_API)) {
$error_page = Config::get('error_page');
if (!empty($error_page)) {
header("Location: {$error_page}");
@@ -48,7 +47,7 @@ class Error
}
/* 收集异常数据 */
if(APP_DEBUG){
if (APP_DEBUG) {
/* 调试模式,获取详细的错误信息 */
$data = [
'name' => get_class($exception),
@@ -60,7 +59,7 @@ class Error
'source' => self::getSourceCode($exception),
'datas' => self::getExtendData($exception),
'tables' => [
'tables' => [
'GET Data' => $_GET,
'POST Data' => $_POST,
'Files' => $_FILES,
@@ -69,13 +68,13 @@ class Error
'Server/Request Data' => $_SERVER,
'Environment Variables' => $_ENV,
'ThinkPHP Constants' => self::getTPConst(),
]
],
];
} else {
/* 部署模式仅显示 Code 和 Message */
$data = [
'code' => $exception->getCode(),
'message' => Config::get('show_error_msg') ? $exception->getMessage() : Config::get('error_message')
'message' => Config::get('show_error_msg') ? $exception->getMessage() : Config::get('error_message'),
];
}
@@ -109,7 +108,7 @@ class Error
*/
public static function appShutdown()
{
if($error = error_get_last()){
if ($error = error_get_last()) {
// 将错误信息托管至think\ErrorException
$exception = new ErrorException(
$error['type'],
@@ -137,9 +136,9 @@ class Error
* @param Array $vars 异常信息
* @return null
*/
public static function output(\Exception $exception, Array $vars)
public static function output(\Exception $exception, array $vars)
{
if($exception instanceof Exception){
if ($exception instanceof Exception) {
http_response_code($exception->getHttpStatus());
} else {
http_response_code(500);
@@ -155,7 +154,7 @@ class Error
// 输出异常内容
Response::send($data, $type, Config::get('response_return'));
} else {
ob_end_clean();
//ob_end_clean();
extract($vars);
include Config::get('exception_tmpl');
}
@@ -171,7 +170,7 @@ class Error
{
$code = $exception->getCode();
if(!$code && $exception instanceof ErrorException){
if (!$code && $exception instanceof ErrorException) {
$code = $exception->getSeverity();
}
@@ -195,9 +194,9 @@ class Error
$source = [
'first' => $first,
'source' => array_slice($contents, $first - 1, 19)
'source' => array_slice($contents, $first - 1, 19),
];
} catch (Exception $e){
} catch (Exception $e) {
$source = [];
}
@@ -214,7 +213,7 @@ class Error
{
$data = [];
if($exception instanceof Exception){
if ($exception instanceof Exception) {
$data = $exception->getData();
}