You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
933 B
41 lines
933 B
|
3 years ago
|
<?php
|
||
|
|
namespace apps\base\controllers;
|
||
|
|
|
||
|
|
class ErrorController extends BaseController {
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 404错误
|
||
|
|
* @param object $e 错误对象
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function error404($e=null) {
|
||
|
|
header('HTTP/1.1 404 Not Found');
|
||
|
|
header("status: 404 Not Found");
|
||
|
|
$this->error($e);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 错误输出
|
||
|
|
* @param object $e 错误对象
|
||
|
|
* @return void
|
||
|
|
*/
|
||
|
|
public function error($e=null){
|
||
|
|
if(false!==stripos(get_class($e), 'Exception')) {
|
||
|
|
$this->errorMessage = $e->getMessage();
|
||
|
|
$this->errorCode = $e->getCode();
|
||
|
|
$this->errorFile = $e->getFile();
|
||
|
|
$this->errorLine = $e->getLine();
|
||
|
|
$this->trace = $e->getTrace();
|
||
|
|
}
|
||
|
|
|
||
|
|
//关闭调试或者是线上版本,不显示详细错误
|
||
|
|
if(false==C('DEBUG') || 'production'==C('ENV')) {
|
||
|
|
$tpl = 'error_production';
|
||
|
|
//记录错误日志
|
||
|
|
|
||
|
|
}else{
|
||
|
|
$tpl = 'error_development';
|
||
|
|
}
|
||
|
|
$this->display('source/apps/base/views/'.$tpl);
|
||
|
|
}
|
||
|
|
}
|