debug: Add comprehensive logging to trace error handling flow

- Add detailed logging to API key validation function
- Add debug logs to frontend error parsing
- Add debug logs to TanStack Query error handler
- This will help identify where error handling is failing in the UI
This commit is contained in:
leex279
2025-09-12 19:47:47 +02:00
parent 98b798173e
commit 082324b7fc
3 changed files with 58 additions and 24 deletions

View File

@@ -18,6 +18,10 @@ export async function callKnowledgeAPI<T>(
// Use the ETag-aware API client for caching benefits
return await callAPIWithETag<T>(endpoint, options);
} catch (error: any) {
console.log(`🔍 [Knowledge API] Caught error for ${endpoint}:`, error);
console.log(`🔍 [Knowledge API] Error type: ${typeof error}`);
console.log(`🔍 [Knowledge API] Error keys:`, Object.keys(error || {}));
// Apply enhanced error parsing for OpenAI errors
const enhancedError = parseKnowledgeBaseError({
status: error.statusCode || error.status,
@@ -25,12 +29,17 @@ export async function callKnowledgeAPI<T>(
detail: error.detail
});
console.log(`🔍 [Knowledge API] Enhanced error:`, enhancedError);
console.log(`🔍 [Knowledge API] Is OpenAI error:`, enhancedError.isOpenAIError);
console.log(`🔍 [Knowledge API] Error details:`, enhancedError.errorDetails);
// Preserve the original error structure but enhance with our parsing
const finalError = error as EnhancedError;
finalError.isOpenAIError = enhancedError.isOpenAIError;
finalError.errorDetails = enhancedError.errorDetails;
finalError.message = enhancedError.message;
console.log(`🔍 [Knowledge API] Final error to throw:`, finalError);
throw finalError;
}
}