Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lobtao committed Jun 7, 2018
1 parent 270c1c2 commit ab546fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions src/BaseRpc.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


abstract class BaseRpc {

protected $func;
protected $args;
protected $callback;
Expand All @@ -26,9 +27,9 @@ protected function exception_handler($exception) {
if ($exception instanceof RpcException) {
$errMsg = $exception->getMessage();
} else {
if(config('showerror')){
if (config('showerror')) {
$errMsg = $exception->getMessage();
}else{
} else {
$errMsg = '系统异常';
}
}
Expand All @@ -41,7 +42,9 @@ protected function exception_handler($exception) {
$msg = sprintf("Trace:%s\nClass: %s\nFile: %s\nLine: %s\n异常描述: %s", $exception->getTraceAsString(), get_class($exception), $exception->getFile(), $exception->getLine(), $exception->getMessage());
if (class_exists('\think\facade\Log')) {
\think\facade\Log::error($msg);
} else {
} else if (class_exists('\workermvc\Log')) {
\workermvc\Log::error($msg);
} else if (is_callable(['\think\Log', 'error'])) {
\think\Log::error($msg);
}

Expand All @@ -60,9 +63,9 @@ protected function callFunc($func, $args) {
$params = explode('_', $func, 2);
if (count($params) != 2) throw new RpcException('请求参数错误');

$svname = ucfirst($params[0]);
$svname = ucfirst($params[0]);
$classname = $this->namespace . $svname . 'Service';
$funcname = $params[1];
$funcname = $params[1];
if (!class_exists($classname)) throw new RpcException('' . $classname . '不存在!');

$object = new $classname();
Expand All @@ -76,7 +79,7 @@ protected function callFunc($func, $args) {
* ajax返回
* @param $result
* @param $callback
* @return \think\response\Json|\think\response\Jsonp
* @return string
*/
protected function ajaxReturn($result, $callback) {

Expand Down
2 changes: 1 addition & 1 deletion src/RpcController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class RpcController extends BaseRpc{
* 主方法
* @param $namespace
* @param null $filter
* @return \think\response\Json|\think\response\Jsonp
* @return string
*/
public function handle($namespace, $filter = null) {

Expand Down

0 comments on commit ab546fa

Please sign in to comment.