mirror of
https://github.com/coleam00/Archon.git
synced 2026-01-01 04:09:08 -05:00
debug: Add detailed logging to error parsing function
Add comprehensive debug logs to parseKnowledgeBaseError to identify why OpenAI error details are not being recognized properly. This will show exactly what data structure is being received and why the error_type detection is failing.
This commit is contained in:
@@ -52,6 +52,10 @@ function isSafeObject(obj: any): boolean {
|
|||||||
* Parse and enhance API errors from knowledge base operations
|
* Parse and enhance API errors from knowledge base operations
|
||||||
*/
|
*/
|
||||||
export function parseKnowledgeBaseError(error: any): EnhancedError {
|
export function parseKnowledgeBaseError(error: any): EnhancedError {
|
||||||
|
console.log(`🔍 [Error Parser] Input error:`, error);
|
||||||
|
console.log(`🔍 [Error Parser] Error type: ${typeof error}`);
|
||||||
|
console.log(`🔍 [Error Parser] Error keys:`, Object.keys(error || {}));
|
||||||
|
|
||||||
// Enhanced input validation
|
// Enhanced input validation
|
||||||
if (!error) {
|
if (!error) {
|
||||||
return createFallbackError('No error information provided');
|
return createFallbackError('No error information provided');
|
||||||
@@ -99,17 +103,28 @@ export function parseKnowledgeBaseError(error: any): EnhancedError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse error details from API response
|
// Parse error details from API response
|
||||||
if (error.error || error.detail) {
|
if (error.detail || error.error) {
|
||||||
const errorData = error.error || error.detail;
|
// Prioritize error.detail (where we put structured OpenAI error data)
|
||||||
|
const errorData = error.detail || error.error;
|
||||||
|
|
||||||
|
console.log(`🔍 [Error Parser] Error data:`, errorData);
|
||||||
|
console.log(`🔍 [Error Parser] Error data type:`, typeof errorData);
|
||||||
|
console.log(`🔍 [Error Parser] Has error_type:`, errorData?.error_type);
|
||||||
|
|
||||||
// Check if it's an OpenAI-specific error
|
// Check if it's an OpenAI-specific error
|
||||||
if (typeof errorData === 'object' && errorData.error_type) {
|
if (typeof errorData === 'object' && errorData?.error_type) {
|
||||||
|
console.log(`🔍 [Error Parser] Detected OpenAI error type: ${errorData.error_type}`);
|
||||||
enhancedError.isOpenAIError = true;
|
enhancedError.isOpenAIError = true;
|
||||||
enhancedError.errorDetails = errorData as OpenAIErrorDetails;
|
enhancedError.errorDetails = errorData as OpenAIErrorDetails;
|
||||||
|
|
||||||
// Override the message with the detailed error message
|
// Override the message with the detailed error message
|
||||||
enhancedError.message = errorData.message || errorData.error || enhancedError.message;
|
enhancedError.message = errorData.message || errorData.error || enhancedError.message;
|
||||||
|
console.log(`🔍 [Error Parser] Set enhanced message: ${enhancedError.message}`);
|
||||||
|
} else {
|
||||||
|
console.log(`🔍 [Error Parser] Not an OpenAI error - errorData type: ${typeof errorData}, has error_type: ${!!errorData?.error_type}`);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
console.log(`🔍 [Error Parser] No error.detail or error.error found`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user