mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-01 04:02:02 +08:00
feat: differentiate fetch models error messages by failure type
Distinguish between missing API key, missing endpoint, auth failure, unsupported provider (404/405), and timeout errors instead of showing a generic failure toast for all cases.
This commit is contained in:
@@ -35,7 +35,11 @@ import {
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { ApiKeySection } from "./shared";
|
||||
import { fetchModelsForConfig, type FetchedModel } from "@/lib/api/model-fetch";
|
||||
import {
|
||||
fetchModelsForConfig,
|
||||
showFetchModelsError,
|
||||
type FetchedModel,
|
||||
} from "@/lib/api/model-fetch";
|
||||
import { openclawApiProtocols } from "@/config/openclawProviderPresets";
|
||||
import type { ProviderCategory, OpenClawModel } from "@/types";
|
||||
|
||||
@@ -129,7 +133,10 @@ export function OpenClawFormFields({
|
||||
// Fetch models from API
|
||||
const handleFetchModels = useCallback(() => {
|
||||
if (!baseUrl || !apiKey) {
|
||||
toast.error(t("providerForm.fetchModelsFailed"));
|
||||
showFetchModelsError(null, t, {
|
||||
hasApiKey: !!apiKey,
|
||||
hasBaseUrl: !!baseUrl,
|
||||
});
|
||||
return;
|
||||
}
|
||||
setIsFetchingModels(true);
|
||||
@@ -146,7 +153,7 @@ export function OpenClawFormFields({
|
||||
})
|
||||
.catch((err) => {
|
||||
console.warn("[ModelFetch] Failed:", err);
|
||||
toast.error(t("providerForm.fetchModelsFailed"));
|
||||
showFetchModelsError(err, t);
|
||||
})
|
||||
.finally(() => setIsFetchingModels(false));
|
||||
}, [baseUrl, apiKey, t]);
|
||||
|
||||
Reference in New Issue
Block a user