getStatusCode() === 404) { //$resp = Response::create(json_encode(ajaxFail($e->getMessage(), -1003, null, true))); $resp = ajaxFail($e->getMessage(), -1003); $handle_flag = true; $e = []; } if ($e instanceof ParamsValidateException) { $resp = ajaxFail('参数' . $e->getMessage(), -1002); $handle_flag = true; if (Config::get('app.APP_DEBUG')) { $e = '参数' . $e->getMessage() . ' request_uri:' . $_SERVER['REQUEST_URI']; }else{ $e = []; } } if ($e instanceof NotLoginException) { $resp = ajaxFail("未登录或登录超时", -1000); $handle_flag = true; $e = []; } if ($e instanceof NoAccessException) { $resp = ajaxFail("权限不足,拒绝操作", -1003); $handle_flag = true; $e = []; } if ($e != []) { $txt = sprintf("异常信息(" . $trace_id . "): %s \r\n", $e); Log::write($txt, 'ERROR'); } if ($handle_flag) { $resp->contentType('application/json'); return $resp; } if (!Config::get('app.APP_DEBUG')) { $resp = ajaxFail("系统异常", -1001, $trace_id); $resp->contentType('application/json'); return $resp; } // 其他错误交给系统处理 return parent::render($request, $e); } }