请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

我在设置 BaseValidate 时 报错 Wrong parameters for Exception

Fatal error:  Wrong parameters for Exception([string $exception [, long $code [, Exception $previous = NULL]]]) in C:\xampp\htdocs\tp5disc\application\api\validate\BaseValidate.php on line 31


public function goCheck(){
        //获取http传入的参数
        //对这些参数效验
        $request = Request::instance();
        $params = $request->param();

        $result = $this->batch()->check($params);

        if(!$result){
            $e = new ParameterException([
                'msg' => $this->error,
            ]);
            throw $e;
        }else{
            return true;
        }
    }

完全按照老师写的?

正在回答 回答被采纳积分+3

插入代码

2回答

爆破熊 2018-11-29 02:57:10

$request = Request::instance();
$params = $request->param();

if (!$this->check($params)){
   $e = new ParameterException();
   $e->msg = is_array($this->error) ? implode(';', $this->error) : $this->error;
   throw $e;
}
return true;

我直接用$e->msg = is_array($this->error) ? implode(';', $this->error) : $this->error;

替代了 $e = new ParameterException([
                'msg' => $this->error,
            ]);

这个就好使了。


0 回复 有任何疑惑可以回复我~
提问者 justin_郑 2017-09-29 17:20:09

搞清楚了 BaseException 里面要加 构造函数 

0 回复 有任何疑惑可以回复我~
  • 怎么加?能告诉我一下么。
    回复 有任何疑惑可以回复我~ 2018-11-29 02:44:30
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号