mirror of
https://github.com/snailyp/gemini-balance.git
synced 2026-09-05 23:56:37 +08:00
feat(error_handling): 增强 API 错误处理和日志记录
- 扩展 ErrorLog 数据模型,增加 model_name, error_type, error_code 字段,以记录更详细的错误信息。 - 在 GeminiChatService 和 OpenAIChatService 中添加了 try-except 块,用于捕获 API 调用(包括普通和流式调用)时发生的异常。 - 实现从异常消息中通过正则表达式提取 HTTP 状态码的功能。 - 调用 add_error_log 服务将详细的错误信息(包括模型、错误类型、代码、请求体)持久化到数据库。 - 更新了 error_logs 前端页面,增加显示模型名称列及详情。 - 优化数据库连接池配置 (pool_recycle=3600),提高连接稳定性。
This commit is contained in:
@@ -64,6 +64,7 @@
|
||||
<th>ID</th>
|
||||
<th>Gemini密钥</th>
|
||||
<th>错误日志</th>
|
||||
<th>模型名称</th>
|
||||
<th>请求时间</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
@@ -138,6 +139,10 @@
|
||||
<h6>请求消息:</h6>
|
||||
<pre id="modalRequestMsg" class="bg-light p-2 rounded"></pre>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<h6>模型名称:</h6>
|
||||
<p id="modalModelName"></p>
|
||||
</div>
|
||||
<div>
|
||||
<h6>请求时间:</h6>
|
||||
<p id="modalRequestTime"></p>
|
||||
|
||||
Reference in New Issue
Block a user