feat: improve error handling for video generation and update duration selection to dropdown
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""Generate router: text, image, video, and image-to-video generation."""
|
||||
from datetime import datetime, timezone
|
||||
|
||||
import httpx
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
|
||||
from ..db import get_conn, get_write_lock
|
||||
@@ -199,9 +200,16 @@ async def generate_video(
|
||||
aspect_ratio=body.aspect_ratio,
|
||||
resolution=body.resolution,
|
||||
)
|
||||
except httpx.HTTPStatusError as exc:
|
||||
detail = (
|
||||
f"OpenRouter API error: {exc.response.status_code} - {exc.response.text}"
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_502_BAD_GATEWAY, detail=detail)
|
||||
except Exception as exc:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_502_BAD_GATEWAY, detail=f"OpenRouter error: {exc}")
|
||||
status_code=status.HTTP_502_BAD_GATEWAY, detail=f"OpenRouter error: {exc}"
|
||||
)
|
||||
|
||||
user_id = current_user.get("id") or current_user.get("sub")
|
||||
job_id = result.get("id", "")
|
||||
@@ -245,9 +253,16 @@ async def generate_video_from_image(
|
||||
aspect_ratio=body.aspect_ratio,
|
||||
resolution=body.resolution,
|
||||
)
|
||||
except httpx.HTTPStatusError as exc:
|
||||
detail = (
|
||||
f"OpenRouter API error: {exc.response.status_code} - {exc.response.text}"
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_502_BAD_GATEWAY, detail=detail)
|
||||
except Exception as exc:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_502_BAD_GATEWAY, detail=f"OpenRouter error: {exc}")
|
||||
status_code=status.HTTP_502_BAD_GATEWAY, detail=f"OpenRouter error: {exc}"
|
||||
)
|
||||
|
||||
user_id = current_user.get("id") or current_user.get("sub")
|
||||
job_id = result.get("id", "")
|
||||
|
||||
Reference in New Issue
Block a user