Skip to content

Commit

Permalink
chg: Improve errors handling, make settings more strict.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Jul 15, 2024
1 parent 9274c0a commit b2d25e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lacuscore/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from enum import IntEnum, unique
from logging import LoggerAdapter
from typing import MutableMapping, Any, TypedDict
from typing import MutableMapping, Any, TypedDict, Literal

from playwrightcapture.capture import CaptureResponse as PlaywrightCaptureResponse

Expand Down Expand Up @@ -77,7 +77,7 @@ class CaptureSettings(TypedDict, total=False):
url: str | None
document_name: str | None
document: str | None
browser: str | None
browser: Literal['chromium', 'firefox', 'webkit'] | None
device_name: str | None
user_agent: str | None
proxy: str | dict[str, str] | None
Expand Down
4 changes: 2 additions & 2 deletions lacuscore/lacuscore.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from dns.exception import Timeout as DNSTimeout

from defang import refang # type: ignore[import-untyped]
from playwrightcapture import Capture, PlaywrightCaptureException
from playwrightcapture import Capture, PlaywrightCaptureException, InvalidPlaywrightParameter
from redis import Redis
from redis.exceptions import ConnectionError as RedisConnectionError
from redis.exceptions import DataError
Expand Down Expand Up @@ -603,7 +603,7 @@ async def _capture(self, uuid: str, priority: int) -> None:
stats_pipeline.zincrby(f'stats:{today}:errors', 1, result['error_name'])
except RetryCapture as e:
raise e
except PlaywrightCaptureException as e:
except (PlaywrightCaptureException, InvalidPlaywrightParameter) as e:
logger.warning(f'Invalid parameters for the capture of {url} - {e}')
result = {'error': f'Invalid parameters for the capture of {url} - {e}'}
raise CaptureError(f'Invalid parameters for the capture of {url} - {e}')
Expand Down

0 comments on commit b2d25e0

Please sign in to comment.