diff --git a/app/login_info.py b/app/login_info.py index a69c18b..9843a3c 100644 --- a/app/login_info.py +++ b/app/login_info.py @@ -23,9 +23,11 @@ def get_recent_login_info(page_index=1, page_size=10): data = response.json() response.raise_for_status() # 如果响应状态码不是 200,会引发 HTTPError logging.debug(f"请求{url} 返回参数: {data}") - except Exception as e: + except ValueError as json_err: # 处理可能的请求错误 - logging.info(f"recent_login_info请求发生错误: {e}") + logging.info(f"online_size解析错误: {json_err}") + except requests.exceptions.HTTPError as http_err: + logging.error(f"online_size请求发生错误: {http_err}") return data @@ -44,8 +46,10 @@ def get_online_size(): logging.debug(f"请求{url} 返回参数: {data}") return data.get('data', {}).get('online_num', 0) - except Exception as e: + except ValueError as json_err: # 处理可能的请求错误 - logging.info(f"online_size请求发生错误: {e}") + logging.info(f"online_size解析错误: {json_err}") + except requests.exceptions.HTTPError as http_err: + logging.error(f"online_size请求发生错误: {http_err}") return 0 \ No newline at end of file