mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-09-02 13:31:38 +08:00
throw_exception方法简化为E方法
删除redirect方法和N方法
This commit is contained in:
@@ -44,7 +44,7 @@ class LocationTemplate {
|
||||
}
|
||||
$templateFile = MODULE_PATH.'view/'.$template.'.html';
|
||||
if(!is_file($templateFile))
|
||||
throw_exception(L('_TEMPLATE_NOT_EXIST_').'['.$templateFile.']');
|
||||
E(L('_TEMPLATE_NOT_EXIST_').'['.$templateFile.']');
|
||||
return $templateFile;
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ class Config {
|
||||
if(class_exists($class)) {
|
||||
self::set((new $class())->parse($config),'',$range);
|
||||
}else{
|
||||
throw_exception('class not exists: ' . $class);
|
||||
E('class not exists: ' . $class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ abstract class Driver {
|
||||
}
|
||||
$this->linkID[$linkNum] = new PDO( $config['dsn'], $config['username'], $config['password'],$config['params']);
|
||||
}catch (\PDOException $e) {
|
||||
throw_exception($e->getMessage());
|
||||
E($e->getMessage());
|
||||
}
|
||||
if(!empty($config['charset'])) {
|
||||
$this->linkID[$linkNum]->exec('SET NAMES '.$config['charset']);
|
||||
@@ -121,7 +121,7 @@ abstract class Driver {
|
||||
$this->debug(true);
|
||||
$this->PDOStatement = $this->_linkID->prepare($str);
|
||||
if(false === $this->PDOStatement)
|
||||
throw_exception($this->error());
|
||||
E($this->error());
|
||||
$result = $this->PDOStatement->execute($bind);
|
||||
// 调试结束
|
||||
$this->debug(false);
|
||||
@@ -150,7 +150,7 @@ abstract class Driver {
|
||||
$this->debug(true);
|
||||
$this->PDOStatement = $this->_linkID->prepare($str);
|
||||
if(false === $this->PDOStatement) {
|
||||
throw_exception($this->error());
|
||||
E($this->error());
|
||||
}
|
||||
$result = $this->PDOStatement->execute($bind);
|
||||
$this->debug(false);
|
||||
@@ -421,7 +421,7 @@ abstract class Driver {
|
||||
}else{
|
||||
// 查询字段的安全过滤
|
||||
if(!preg_match('/^[A-Z_\|\&\-.a-z0-9\(\)\,]+$/',trim($key))){
|
||||
throw_exception(L('_EXPRESS_ERROR_').':'.$key);
|
||||
E(L('_EXPRESS_ERROR_').':'.$key);
|
||||
}
|
||||
// 多条件支持
|
||||
$multi = is_array($val) && isset($val['_multi']);
|
||||
@@ -490,7 +490,7 @@ abstract class Driver {
|
||||
$data = is_string($val[1])? explode(',',$val[1]):$val[1];
|
||||
$whereStr .= ' ('.$key.' '.strtoupper($val[0]).' '.$this->parseValue($data[0]).' AND '.$this->parseValue($data[1]).' )';
|
||||
}else{
|
||||
throw_exception(L('_EXPRESS_ERROR_').':'.$val[0]);
|
||||
E(L('_EXPRESS_ERROR_').':'.$val[0]);
|
||||
}
|
||||
}else {
|
||||
$count = count($val);
|
||||
|
||||
@@ -41,13 +41,13 @@ class Oracle extends Driver{
|
||||
if ( !empty($this->PDOStatement) ) $this->free();
|
||||
$this->executeTimes++;
|
||||
// 记录开始执行时间
|
||||
Debug::remark('queryStartTime','time');
|
||||
$this->debug(true);
|
||||
$this->PDOStatement = $this->_linkID->prepare($str);
|
||||
if(false === $this->PDOStatement) {
|
||||
throw_exception($this->error());
|
||||
E($this->error());
|
||||
}
|
||||
$result = $this->PDOStatement->execute($bind);
|
||||
$this->debug();
|
||||
$this->debug(false);
|
||||
if ( false === $result) {
|
||||
$this->error();
|
||||
return false;
|
||||
|
||||
@@ -82,7 +82,7 @@ class Lite {
|
||||
}
|
||||
$this->linkID[$linkNum] = new PDO( $config['dsn'], $config['username'], $config['password'],$config['params']);
|
||||
}catch (\PDOException $e) {
|
||||
throw_exception($e->getMessage());
|
||||
E($e->getMessage());
|
||||
}
|
||||
if(!empty($config['charset'])) {
|
||||
$this->linkID[$linkNum]->exec('SET NAMES '.$config['charset']);
|
||||
@@ -117,7 +117,7 @@ class Lite {
|
||||
$this->debug(true);
|
||||
$this->PDOStatement = $this->_linkID->prepare($str);
|
||||
if(false === $this->PDOStatement)
|
||||
throw_exception($this->error());
|
||||
E($this->error());
|
||||
$result = $this->PDOStatement->execute($bind);
|
||||
$this->debug(false);
|
||||
if ( false === $result ) {
|
||||
@@ -145,7 +145,7 @@ class Lite {
|
||||
$this->debug(true);
|
||||
$this->PDOStatement = $this->_linkID->prepare($str);
|
||||
if(false === $this->PDOStatement) {
|
||||
throw_exception($this->error());
|
||||
E($this->error());
|
||||
}
|
||||
$result = $this->PDOStatement->execute($bind);
|
||||
$this->debug(false);
|
||||
|
||||
@@ -11,70 +11,4 @@
|
||||
// $Id$
|
||||
namespace Think;
|
||||
class Exception extends \Exception {
|
||||
|
||||
/**
|
||||
* 异常类型
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
private $type;
|
||||
|
||||
// 是否存在多余调试信息
|
||||
private $extra;
|
||||
|
||||
/**
|
||||
* 架构函数
|
||||
* @access public
|
||||
* @param string $message 异常信息
|
||||
*/
|
||||
public function __construct($message,$code=0,$extra=false) {
|
||||
parent::__construct($message,$code);
|
||||
$this->type = get_class($this);
|
||||
$this->extra = $extra;
|
||||
}
|
||||
|
||||
/**
|
||||
* 异常输出 所有异常处理类均通过__toString方法输出错误
|
||||
* 每次异常都会写入系统日志
|
||||
* 该方法可以被子类重载
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function __toString() {
|
||||
$trace = $this->getTrace();
|
||||
if($this->extra)
|
||||
// 通过throw_exception抛出的异常要去掉多余的调试信息
|
||||
array_shift($trace);
|
||||
$this->class = isset($trace[0]['class'])?$trace[0]['class']:'';
|
||||
$this->function = isset($trace[0]['function'])?$trace[0]['function']:'';
|
||||
$this->file = $trace[0]['file'];
|
||||
$this->line = $trace[0]['line'];
|
||||
$file = file($this->file);
|
||||
$traceInfo = '';
|
||||
$time = date('y-m-d H:i:m');
|
||||
foreach($trace as $t) {
|
||||
$traceInfo .= '['.$time.'] '.$t['file'].' ('.$t['line'].') ';
|
||||
$traceInfo .= $t['class'].$t['type'].$t['function'].'(';
|
||||
$traceInfo .= implode(', ', $t['args']);
|
||||
$traceInfo .=")\n";
|
||||
}
|
||||
$error['message'] = $this->message;
|
||||
$error['type'] = $this->type;
|
||||
$error['detail'] = ($this->line-2).': '.$file[$this->line-3];
|
||||
$error['detail'] .= ($this->line-1).': '.$file[$this->line-2];
|
||||
$error['detail'] .= '<font color="#FF6600" >'.($this->line).': <strong>'.$file[$this->line-1].'</strong></font>';
|
||||
$error['detail'] .= ($this->line+1).': '.$file[$this->line];
|
||||
$error['detail'] .= ($this->line+2).': '.$file[$this->line+1];
|
||||
$error['class'] = $this->class;
|
||||
$error['function'] = $this->function;
|
||||
$error['file'] = $this->file;
|
||||
$error['line'] = $this->line;
|
||||
$error['trace'] = $traceInfo;
|
||||
|
||||
// 记录 Exception 日志
|
||||
if(C('LOG_EXCEPTION_RECORD')) {
|
||||
ThinkLog::Write('('.$this->type.') '.$this->message);
|
||||
}
|
||||
return $error ;
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,7 @@ class Imagick{
|
||||
*/
|
||||
public function __construct($imgname = null) {
|
||||
if ( !extension_loaded('Imagick') ) {
|
||||
throw_exception(__('_NOT_SUPPERT_').':Imagick');
|
||||
E(L('_NOT_SUPPERT_').':Imagick');
|
||||
}
|
||||
$imgname && $this->open($imgname);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class Log {
|
||||
return self::$handler;
|
||||
}else {
|
||||
// 类没有定义
|
||||
throw_exception(Lang::get('_CLASS_NOT_EXIST_').': ' . $class);
|
||||
E(L('_CLASS_NOT_EXIST_').': ' . $class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -960,7 +960,7 @@ class Model {
|
||||
}elseif(is_string($data)){
|
||||
parse_str($data,$data);
|
||||
}elseif(!is_array($data)){
|
||||
throw_exception(L('_DATA_TYPE_INVALID_'));
|
||||
E(L('_DATA_TYPE_INVALID_'));
|
||||
}
|
||||
$this->data = $data;
|
||||
return $this;
|
||||
@@ -1007,7 +1007,7 @@ class Model {
|
||||
$options = $union;
|
||||
}
|
||||
}else{
|
||||
throw_exception(L('_DATA_TYPE_INVALID_'));
|
||||
E(L('_DATA_TYPE_INVALID_'));
|
||||
}
|
||||
$this->options['union'][] = $options;
|
||||
return $this;
|
||||
|
||||
@@ -85,7 +85,7 @@ class Diandian extends Driver{
|
||||
$userInfo['avatar'] = "https://api.diandian.com/v1/blog/{$data['response']['blogs'][0]['blogUuid']}/avatar/144";
|
||||
return $userInfo;
|
||||
} else {
|
||||
throw_exception("获取点点用户信息失败:{$data}");
|
||||
E("获取点点用户信息失败:{$data}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ class Douban extends Driver{
|
||||
$userInfo['avatar'] = $data['avatar'];
|
||||
return $userInfo;
|
||||
} else {
|
||||
throw_exception("获取豆瓣用户信息失败:{$data['msg']}");
|
||||
E("获取豆瓣用户信息失败:{$data['msg']}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ class Github extends Driver{
|
||||
$userInfo['avatar'] = $data['avatar_url'];
|
||||
return $userInfo;
|
||||
} else {
|
||||
throw_exception("获取Github用户信息失败:{$data}");
|
||||
E("获取Github用户信息失败:{$data}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ class Google extends Driver{
|
||||
$userInfo['avatar'] = $data['picture'];
|
||||
return $userInfo;
|
||||
} else {
|
||||
throw_exception("获取Google用户信息失败:{$data}");
|
||||
E("获取Google用户信息失败:{$data}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ class Kaixin extends Driver{
|
||||
$userInfo['avatar'] = $data['logo50'];
|
||||
return $userInfo;
|
||||
} else {
|
||||
throw_exception("获取开心网用户信息失败:{$data['error']}");
|
||||
E("获取开心网用户信息失败:{$data['error']}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ class Msn extends Driver{
|
||||
$userInfo['avatar'] = '微软暂未提供头像URL,请通过 me/picture 接口下载';
|
||||
return $userInfo;
|
||||
} else {
|
||||
throw_exception("获取msn用户信息失败:{$data}");
|
||||
E("获取msn用户信息失败:{$data}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ class Qq extends Driver{
|
||||
$userInfo['avatar'] = $data['figureurl_2'];
|
||||
return $userInfo;
|
||||
} else {
|
||||
throw_exception("获取腾讯QQ用户信息失败:{$data['msg']}");
|
||||
E("获取腾讯QQ用户信息失败:{$data['msg']}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class Renren extends Driver{
|
||||
$userInfo['avatar'] = $data[0]['headurl'];
|
||||
return $userInfo;
|
||||
} else {
|
||||
throw_exception("获取人人网用户信息失败:{$data['error_msg']}");
|
||||
E("获取人人网用户信息失败:{$data['error_msg']}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ class Sina extends Driver{
|
||||
$userInfo['avatar'] = $data[0]['headurl'];
|
||||
return $userInfo;
|
||||
} else {
|
||||
throw_exception("获取人人网用户信息失败:{$data['error_msg']}");
|
||||
E("获取人人网用户信息失败:{$data['error_msg']}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ class Sohu extends Driver{
|
||||
$userInfo['avatar'] = $data['data']['icon'];
|
||||
return $userInfo;
|
||||
} else {
|
||||
throw_exception("获取搜狐用户信息失败:{$data['message']}");
|
||||
E("获取搜狐用户信息失败:{$data['message']}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ class T163 extends Driver{
|
||||
$userInfo['avatar'] = str_replace('w=48&h=48', 'w=180&h=180', $data['profile_image_url']);
|
||||
return $userInfo;
|
||||
} else {
|
||||
throw_exception("获取网易微博用户信息失败:{$data['error']}");
|
||||
E("获取网易微博用户信息失败:{$data['error']}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ class Taobao extends Driver{
|
||||
$userInfo['avatar'] = $user['avatar'];
|
||||
return $userInfo;
|
||||
} else {
|
||||
throw_exception("获取淘宝网用户信息失败:{$data['error_response']['msg']}");
|
||||
E("获取淘宝网用户信息失败:{$data['error_response']['msg']}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ class Tencent extends Driver{
|
||||
$userInfo['avatar'] = $data[0]['headurl'];
|
||||
return $userInfo;
|
||||
} else {
|
||||
throw_exception("获取人人网用户信息失败:{$data['error_msg']}");
|
||||
E("获取人人网用户信息失败:{$data['error_msg']}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ class X360 extends Driver{
|
||||
$userInfo['avatar'] = $data['avatar'];
|
||||
return $userInfo;
|
||||
} else {
|
||||
throw_exception("获取360用户信息失败:{$data['error']}");
|
||||
E("获取360用户信息失败:{$data['error']}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ abstract class Rest {
|
||||
$this->$fun();
|
||||
}else{
|
||||
// 抛出异常
|
||||
throw_exception(L('_ERROR_ACTION_:').ACTION_NAME);
|
||||
E(L('_ERROR_ACTION_:').ACTION_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class Session {
|
||||
$hander->execute();
|
||||
}else {
|
||||
// 类没有定义
|
||||
throw_exception(Lang::get('_CLASS_NOT_EXIST_').': ' . $class);
|
||||
E(L('_CLASS_NOT_EXIST_').': ' . $class);
|
||||
}
|
||||
}
|
||||
// 启动session
|
||||
|
||||
@@ -20,7 +20,7 @@ class File {
|
||||
mkdir($dir,0755,true);
|
||||
// 生成模板缓存文件
|
||||
if( false === file_put_contents($cacheFile,$content))
|
||||
throw_exception('_CACHE_WRITE_ERROR_:'.$cacheFile);
|
||||
E('_CACHE_WRITE_ERROR_:'.$cacheFile);
|
||||
}
|
||||
|
||||
// 读取编译编译
|
||||
|
||||
Reference in New Issue
Block a user