pinguo / php-msf

PHP微服务框架即Micro Service Framework For PHP
GNU General Public License v2.0
1.75k stars 317 forks source link

controller yield Exception问题,严重! #77

Closed wuchuguang closed 6 years ago

wuchuguang commented 6 years ago
class C extends Controller {
 public function actionIndex(){
          $user = $this->getObject(User::class);//User class
           $result = yield $user->login();//这里有throw new LoginFailException();的情况。
           $this->outputJson($result);
 }
public function onExceptionHandle(\Throwable $e)
    {
        if($e instanceof LoginFailException){//这里没有catch到上面的异常。
            $this->outputJson(['message'=>$e->getMessage()], 401);
            return;
        }
      parent::onExceptionHandle($e);
 }
}

当login throw LoginFailException会报如下错: [2017-10-12 19:46:12 *29162.0] ERROR zm_deactivate_swoole (ERROR 503): Fatal error: Uncaught App\Exceptions\LoginFailException: 账号或密码错误:0,剩除次数:0 in /opt/rondaful-b2c/msf-server/app/Service/User.php:36 Stack trace:

0 [internal function]: App\Service\User->login('admin1', 'admin', 10)

1 /opt/rondaful-b2c/msf-server/vendor/pinguo/php-msf/src/Coroutine/Task.php(159): Generator->send(NULL)

2 /opt/rondaful-b2c/msf-server/vendor/pinguo/php-msf/src/Coroutine/Scheduler.php(99): PG\MSF\Coroutine\Task->run()

3 /opt/rondaful

[2017-10-12 19:46:12 $29159.0] WARNING swManager_check_exit_status: worker#0 abnormal exit, status=255, signal=0 [2017-10-12 19:46:12] 服务器进程异常退出 WORKER Error {"worker_id":0,"worker_pid":29162,"exit_code":255,"message":null}

xudianyang commented 6 years ago

75 已修复