From 6899c7792ef51831f64d07426956490b35639e9a Mon Sep 17 00:00:00 2001 From: Abi Raja Date: Fri, 20 Sep 2024 13:56:20 +0200 Subject: [PATCH] when all generations fail, print the all the underlying exceptions for debugging --- backend/routes/generate_code.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/routes/generate_code.py b/backend/routes/generate_code.py index e454ad0..866c7c0 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