fix: add error logging and error type to AI builder 502 responses
The generic "AI provider error" message made debugging impossible. Now logs the full exception traceback and includes the error class name in the 502 response detail. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -195,6 +195,7 @@ async def scaffold(
|
||||
detail=f"AI returned invalid output: {e}",
|
||||
)
|
||||
except Exception as e:
|
||||
logger.exception("AI scaffold failed: %s: %s", type(e).__name__, e)
|
||||
await record_ai_usage(
|
||||
user_id=current_user.id,
|
||||
account_id=current_user.account_id,
|
||||
@@ -213,7 +214,7 @@ async def scaffold(
|
||||
await db.commit()
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_502_BAD_GATEWAY,
|
||||
detail="AI provider error. Please try again.",
|
||||
detail=f"AI provider error ({type(e).__name__}). Please try again.",
|
||||
)
|
||||
|
||||
# Record successful usage
|
||||
@@ -314,6 +315,7 @@ async def branch_detail(
|
||||
detail=f"AI returned invalid output: {e}",
|
||||
)
|
||||
except Exception as e:
|
||||
logger.exception("AI branch_detail failed: %s: %s", type(e).__name__, e)
|
||||
await record_ai_usage(
|
||||
user_id=current_user.id,
|
||||
account_id=current_user.account_id,
|
||||
@@ -332,7 +334,7 @@ async def branch_detail(
|
||||
await db.commit()
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_502_BAD_GATEWAY,
|
||||
detail="AI provider error. Please try again.",
|
||||
detail=f"AI provider error ({type(e).__name__}). Please try again.",
|
||||
)
|
||||
|
||||
# Record successful usage
|
||||
|
||||
Reference in New Issue
Block a user