美文网首页
TP5.1中关于$this->success()异常报错

TP5.1中关于$this->success()异常报错

作者: 王兴伍 | 来源:发表于2020-03-24 16:28 被阅读0次

    TP5.1中关于$this->success()后续继续执行,被try catch异常的捕获了导致返回一直是异常。

    错误代码

    try {

    .......

    $this->success("操作成功");

    } catch (\Exception $e) {

            $this->error("异常操作,{$e->getMessage()}");

    }

    正确代码

    try {

    .......

    $this->success("操作成功");

    }catch (HttpResponseException $exception){

            throw $exception;

    } catch (\Exception $e) {

            $this->error("异常操作,{$e->getMessage()}");

    }

    相关文章

      网友评论

          本文标题:TP5.1中关于$this->success()异常报错

          本文链接:https://www.haomeiwen.com/subject/yrzoyhtx.html