Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

when all generations fail, print the all the underlying exceptions for debugging

Abi Raja6899c7792ef5
diff --git a/backend/routes/generate_code.py b/backend/routes/generate_code.py
index e454ad05..866c7c0f 100644
--- a/backend/routes/generate_code.py
+++ b/backend/routes/generate_code.py
@@ -1,5 +1,6 @@
import asyncio
from dataclasses import dataclass
+import traceback
from fastapi import APIRouter, WebSocket
import openai
from codegen.utils import extract_html_content
@@ -321,6 +322,12 @@ async def stream_code(websocket: WebSocket):
)
if all_generations_failed:
await throw_error("Error generating code. Please contact support.")
+
+ # Print the all the underlying exceptions for debugging
+ for completion in completions:
+ traceback.print_exception(
+ type(completion), completion, completion.__traceback__
+ )
raise Exception("All generations failed")
# If some completions failed, replace them with empty strings