mirror of
https://github.com/fawney19/Aether.git
synced 2026-01-12 04:28:28 +08:00
feat(ui): 优化上游模型查询错误提示
新增 parseUpstreamModelError 函数,将后端返回的原始错误信息 转换为用户友好的中文提示,支持解析 HTTP 状态码和 JSON 错误体
This commit is contained in:
@@ -334,7 +334,7 @@ import {
|
||||
} from 'lucide-vue-next'
|
||||
import { Dialog, Button, Input, Checkbox, Badge } from '@/components/ui'
|
||||
import { useToast } from '@/composables/useToast'
|
||||
import { parseApiError } from '@/utils/errorParser'
|
||||
import { parseApiError, parseUpstreamModelError } from '@/utils/errorParser'
|
||||
import {
|
||||
updateProviderKey,
|
||||
API_FORMAT_LABELS,
|
||||
@@ -522,11 +522,17 @@ async function fetchUpstreamModels() {
|
||||
}
|
||||
collapsedGroups.value = allGroups
|
||||
} else {
|
||||
showError(response.data?.error || '获取上游模型失败', '错误')
|
||||
// 使用友好的错误解析
|
||||
const errorMsg = response.data?.error
|
||||
? parseUpstreamModelError(response.data.error)
|
||||
: '获取上游模型失败'
|
||||
showError(errorMsg, '获取上游模型失败')
|
||||
}
|
||||
} catch (err: any) {
|
||||
if (loadingCancelled) return
|
||||
showError(err.response?.data?.detail || '获取上游模型失败', '错误')
|
||||
// 使用友好的错误解析
|
||||
const rawError = err.response?.data?.detail || err.message || '获取上游模型失败'
|
||||
showError(parseUpstreamModelError(rawError), '获取上游模型失败')
|
||||
} finally {
|
||||
fetchingUpstreamModels.value = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user