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:
@@ -509,7 +509,7 @@ def llm_text_gen(
|
|||||||
status_code=429,
|
status_code=429,
|
||||||
detail={
|
detail={
|
||||||
"error": "All LLM providers failed",
|
"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": {
|
"usage_info": {
|
||||||
"error_type": "all_providers_failed",
|
"error_type": "all_providers_failed",
|
||||||
"operation_type": "text-generation",
|
"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:
|
except Exception as e:
|
||||||
logger.error(f"[llm_text_gen] Error during text generation: {str(e)}")
|
logger.error(f"[llm_text_gen] Error during text generation: {str(e)}")
|
||||||
raise
|
raise
|
||||||
|
|||||||
Reference in New Issue
Block a user