From b90a4afc73a9e0acd51ede168d08ff7647be9233 Mon Sep 17 00:00:00 2001 From: i701 Date: Sun, 13 Jul 2025 22:41:26 +0500 Subject: [PATCH] =?UTF-8?q?fix:=20enhance=20error=20handling=20in=20handle?= =?UTF-8?q?ApiResponse=20function=20for=20better=20clarity=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/tryCatch.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/tryCatch.ts b/utils/tryCatch.ts index f70bbf0..4269b23 100644 --- a/utils/tryCatch.ts +++ b/utils/tryCatch.ts @@ -11,7 +11,7 @@ export async function handleApiResponse( response: Response, fnName?: string, ) { - const responseData = await response.json(); + const responseData = await response.json() if (response.status === 401) { console.log('response data', responseData) throw new Error("UNAUTHORIZED"); @@ -32,7 +32,7 @@ export async function handleApiResponse( if (!response.ok) { console.log(`API Error Response from ${fnName}:`, responseData); - throw new Error(responseData.message || "Something went wrong."); + throw new Error(responseData.message || responseData.detail || "Something went wrong."); } return responseData as T;