From bf49fdf0bf098db9dfcbd1c239c3dee7451a7ce9 Mon Sep 17 00:00:00 2001 From: Nyaru Toru <212608942+nyatoru@users.noreply.github.com> Date: Tue, 24 Feb 2026 21:29:21 +0700 Subject: [PATCH] fix: improve error handling in custom model API call Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- src/app/(dashboard)/dashboard/providers/[id]/page.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/app/(dashboard)/dashboard/providers/[id]/page.tsx b/src/app/(dashboard)/dashboard/providers/[id]/page.tsx index 5a49ebe6a2..3e56f81d1f 100644 --- a/src/app/(dashboard)/dashboard/providers/[id]/page.tsx +++ b/src/app/(dashboard)/dashboard/providers/[id]/page.tsx @@ -1511,9 +1511,15 @@ function CompatibleModelsSection({ }); if (!customModelRes.ok) { - const errorData = await customModelRes.json().catch(() => ({})); + let errorData = {}; + try { + errorData = await customModelRes.json(); + } catch (jsonError) { + console.error("Failed to parse error response from custom model API:", jsonError); + } throw new Error(errorData.error?.message || "Failed to save custom model"); } + } // Only create alias after customModel is saved successfully await onSetAlias(modelId, resolvedAlias, providerStorageAlias);