mirror of
https://github.com/snailyp/gemini-balance.git
synced 2026-09-05 07:26:39 +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:
@@ -109,6 +109,7 @@ function renderErrorLogs() {
|
||||
<td>${log.id}</td>
|
||||
<td>${log.gemini_key || '无'}</td>
|
||||
<td class="error-log-content">${errorLogContent}</td>
|
||||
<td>${log.model_name || '未知'}</td>
|
||||
<td>${formattedTime}</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-primary btn-view-details" data-log-id="${log.id}">
|
||||
@@ -168,6 +169,8 @@ function showLogDetails(logId) {
|
||||
document.getElementById('modalGeminiKey').textContent = log.gemini_key || '无';
|
||||
document.getElementById('modalErrorLog').textContent = log.error_log || '无';
|
||||
document.getElementById('modalRequestMsg').textContent = formattedRequestMsg;
|
||||
// Add model name display logic here - assuming an element with id 'modalModelName' exists
|
||||
document.getElementById('modalModelName').textContent = log.model_name || '未知';
|
||||
document.getElementById('modalRequestTime').textContent = formattedTime;
|
||||
|
||||
// 显示模态框
|
||||
|
||||
Reference in New Issue
Block a user