Add verbose exception debugging for empty error messages

Log full exception details: type, module, str, repr, args, and __dict__
to diagnose why Gemini errors are producing empty messages.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
michael 2026-01-07 13:39:15 -06:00
parent faf58e2723
commit 1a571b01c7

View file

@ -300,9 +300,17 @@ class LLMService:
except Exception as e:
# Fallback for OpenAI and other non-Google errors
last_error = e
error_message = str(e).lower()
# Debug: capture full exception details
exc_type = type(e).__name__
exc_module = type(e).__module__
exc_str = str(e)
exc_repr = repr(e)
exc_args = getattr(e, 'args', ())
exc_dict = getattr(e, '__dict__', {})
logger.warning(f"LLM attempt {attempt_num}/{max_retries} failed: {str(e)}")
logger.warning(f"LLM attempt {attempt_num}/{max_retries} failed - Type: {exc_module}.{exc_type}, str: '{exc_str}', repr: {exc_repr}, args: {exc_args}, dict: {exc_dict}")
error_message = exc_str.lower() if exc_str else exc_repr.lower()
# Check if this is a retryable error (API internal errors, rate limiting, etc.)
if ("500" in error_message or
@ -331,7 +339,8 @@ class LLMService:
error_msg = getattr(last_error, 'message', str(last_error)) or str(last_error) or repr(last_error)
error_detail = f"[Google API {error_code}] {error_msg}"
else:
error_detail = str(last_error)
# Use repr if str is empty
error_detail = str(last_error) or repr(last_error) or f"{type(last_error).__module__}.{type(last_error).__name__}: {getattr(last_error, 'args', ())}"
logger.error(f"LLM content generation failed after {max_retries} attempts. Final error: {error_detail}")
raise LLMServiceError(f"Error generating content: {error_detail}")