fix exception

This commit is contained in:
ThePhaseless
2025-09-10 20:47:59 +00:00
parent 5f053ecd29
commit 9ffc2bb5b3
+6 -4
View File
@@ -6,7 +6,6 @@ from typing import Annotated
from fastapi import APIRouter, Depends, HTTPException
from fastapi.responses import RedirectResponse
from httpx import TimeoutException
from playwright_captcha import CaptchaType
from src.consts import CHALLENGE_TITLES
@@ -79,9 +78,12 @@ async def read_item(request: LinkRequest, dep: CamoufoxDep) -> LinkResponse:
),
timeout=remaining_timeout,
)
except TimeoutException as e:
logger.error("Failed to solve challenge: %s", e)
return LinkResponse.invalid(url=request.url)
except TimeoutError as e:
logger.error("Timed out while solving the challenge")
raise HTTPException(
status_code=408,
detail="Timed out while solving the challenge",
) from e
logger.debug("Challenge solved successfully.")
cookies = await dep.context.cookies()