mirror of
https://github.com/coleam00/Archon.git
synced 2026-01-01 04:09:08 -05:00
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:
@@ -260,6 +260,11 @@ export function useCrawlUrl() {
|
||||
return response;
|
||||
},
|
||||
onError: (error, _variables, context) => {
|
||||
console.log(`🔍 [Crawl Hook] Received error:`, error);
|
||||
console.log(`🔍 [Crawl Hook] Error type: ${typeof error}`);
|
||||
console.log(`🔍 [Crawl Hook] Error keys:`, Object.keys(error || {}));
|
||||
console.log(`🔍 [Crawl Hook] Is OpenAI error:`, (error as EnhancedError)?.isOpenAIError);
|
||||
|
||||
// Rollback optimistic updates on error
|
||||
if (context?.previousKnowledge) {
|
||||
queryClient.setQueryData(knowledgeKeys.lists(), context.previousKnowledge);
|
||||
@@ -278,6 +283,8 @@ export function useCrawlUrl() {
|
||||
const errorMessage = (error as EnhancedError)?.isOpenAIError
|
||||
? getDisplayErrorMessage(error as EnhancedError)
|
||||
: (error instanceof Error ? error.message : "Failed to start crawl");
|
||||
|
||||
console.log(`🔍 [Crawl Hook] Final error message for toast:`, errorMessage);
|
||||
showToast(errorMessage, "error");
|
||||
},
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user