getMessage(); // 验证异常 if ($e instanceof \think\exception\ValidateException) { $code = 0; $statuscode = 200; $msg = $e->getError(); } // Http异常 if ($e instanceof \think\exception\HttpException) { $statuscode = $code = $e->getStatusCode(); $msg = $e->getMessage(); } return json(['code' => $code, 'msg' => $msg, 'time' => time(), 'data' => null], $statuscode); } //其它此交由系统处理 return parent::render($e); } }