Fix error handling in main_text_generation.py

- Add HTTPException re-raise before generic Exception handler
- Use static error message instead of str(e) which was out of scope
- Fixes 'e is not associated with a value' error
This commit is contained in:
ajaysi
2026-03-31 19:38:54 +05:30
parent 35fd700b22
commit 4c206293b1

View File

@@ -509,7 +509,7 @@ def llm_text_gen(
status_code=429,
detail={
"error": "All LLM providers failed",
"message": str(e),
"message": "All configured LLM providers failed to generate a response. Please check API keys and try again.",
"usage_info": {
"error_type": "all_providers_failed",
"operation_type": "text-generation",
@@ -522,6 +522,9 @@ def llm_text_gen(
}
)
except HTTPException:
# Re-raise HTTPExceptions (e.g., 429 subscription limit) - preserve error details
raise
except Exception as e:
logger.error(f"[llm_text_gen] Error during text generation: {str(e)}")
raise