改进控制器类不存在的异常处理

This commit is contained in:
thinkphp
2016-06-28 17:42:28 +08:00
parent 802ead16a8
commit ef71b5e81d
3 changed files with 47 additions and 46 deletions

View File

@@ -11,49 +11,50 @@
// 核心中文语言包 // 核心中文语言包
return [ return [
// 系统错误提示 // 系统错误提示
'Undefined variable' => '未定义变量', 'Undefined variable' => '未定义变量',
'Undefined index' => '未定义索引', 'Undefined index' => '未定义索引',
'Parse error' => '语法解析错误', 'Parse error' => '语法解析错误',
'Type error' => '类型错误', 'Type error' => '类型错误',
'Fatal error' => '致命错误', 'Fatal error' => '致命错误',
// 框架核心错误提示 // 框架核心错误提示
'dispatch type not support' => '不支持的调度类型', 'dispatch type not support' => '不支持的调度类型',
'method param miss' => '方法参数错误', 'method param miss' => '方法参数错误',
'method not exists' => '方法不存在', 'method not exists' => '方法不存在',
'module not exists' => '模块不存在', 'module not exists' => '模块不存在',
'class not exists' => '不存在', 'controller not exists' => '控制器不存在',
'template not exists' => '模板文件不存在', 'class not exists' => '不存在',
'illegal controller name' => '非法的控制器名称', 'template not exists' => '模板文件不存在',
'illegal action name' => '非法的操作名称', 'illegal controller name' => '非法的控制器名称',
'url suffix deny' => '禁止的URL后缀访问', 'illegal action name' => '非法的操作名称',
'Route Not Found' => '当前访问路由未定义', 'url suffix deny' => '禁止的URL后缀访问',
'Underfined db type' => '未定义数据库类型', 'Route Not Found' => '当前访问路由未定义',
'variable type error' => '变量类型错误', 'Underfined db type' => '未定义数据库类型',
'PSR-4 error' => 'PSR-4 规范错误', 'variable type error' => '变量类型错误',
'not support total' => '简洁模式下不能获取数据总数', 'PSR-4 error' => 'PSR-4 规范错误',
'not support last' => '简洁模式下不能获取最后一页', 'not support total' => '简洁模式下不能获取数据总数',
'error session handler' => '错误的SESSION处理器类', 'not support last' => '简洁模式下不能获取最后一页',
'not allow php tag' => '模板不允许使用PHP语法', 'error session handler' => '错误的SESSION处理器类',
'not support' => '不支持', 'not allow php tag' => '模板不允许使用PHP语法',
'redisd master' => 'Redisd 主服务器错误', 'not support' => '不支持',
'redisd slave' => 'Redisd 服务器错误', 'redisd master' => 'Redisd 服务器错误',
'must run at sae' => '必须在SAE运行', 'redisd slave' => 'Redisd 从服务器错误',
'memcache init error' => '未开通Memcache服务请在SAE管理平台初始化Memcache服务', 'must run at sae' => '必须在SAE运行',
'KVDB init error' => '没有初始化KVDB请在SAE管理平台初始化KVDB服务', 'memcache init error' => '未开通Memcache服务请在SAE管理平台初始化Memcache服务',
'fields not exists' => '数据表字段不存在', 'KVDB init error' => '没有初始化KVDB请在SAE管理平台初始化KVDB服务',
'where express error' => '查询表达式错误', 'fields not exists' => '数据表字段不存在',
'no data to update' => '没有任何数据需要更新', 'where express error' => '查询表达式错误',
'miss data to insert' => '缺少需要写入的数据', 'no data to update' => '没有任何数据需要更新',
'miss complex primary data' => '缺少复合主键数据', 'miss data to insert' => '缺少需要写入的数据',
'miss update condition' => '缺少更新条件', 'miss complex primary data' => '缺少复合主键数据',
'model data Not Found' => '模型数据不存在', 'miss update condition' => '缺少更新条件',
'table data not Found' => '数据不存在', 'model data Not Found' => '模型数据不存在',
'delete without condition' => '没有条件不会执行删除操作', 'table data not Found' => '表数据不存在',
'miss relation data' => '缺少关联表数据', 'delete without condition' => '没有条件不会执行删除操作',
'tag attr must' => '模板标签属性必须', 'miss relation data' => '缺少关联表数据',
'tag error' => '模板标签错误', 'tag attr must' => '模板标签属性必须',
'cache write error' => '缓存写入失败', 'tag error' => '模板标签错误',
'sae mc write error' => 'SAE mc 写入错误', 'cache write error' => '缓存写入失败',
'sae mc write error' => 'SAE mc 写入错误',
]; ];

View File

@@ -307,7 +307,9 @@ class App
try { try {
$instance = Loader::controller($controller, $config['url_controller_layer'], $config['controller_suffix'], $config['empty_controller']); $instance = Loader::controller($controller, $config['url_controller_layer'], $config['controller_suffix'], $config['empty_controller']);
if (is_null($instance)) {
throw new HttpException(404, 'controller not exists:' . $controller);
}
// 获取当前操作名 // 获取当前操作名
$action = $actionName . $config['action_suffix']; $action = $actionName . $config['action_suffix'];
if (!preg_match('/^[A-Za-z](\w)*$/', $action)) { if (!preg_match('/^[A-Za-z](\w)*$/', $action)) {

View File

@@ -351,8 +351,6 @@ class Loader
return new $class(Request::instance()); return new $class(Request::instance());
} elseif ($empty && class_exists($emptyClass = self::parseClass($module, $layer, $empty, $appendSuffix))) { } elseif ($empty && class_exists($emptyClass = self::parseClass($module, $layer, $empty, $appendSuffix))) {
return new $emptyClass(Request::instance()); return new $emptyClass(Request::instance());
} else {
throw new ClassNotFoundException('class not exists:' . $class, $class);
} }
} }