Exception handling

This commit is contained in:
daijro
2026-02-07 03:29:35 -06:00
parent 61a9e1f9bb
commit 0923b12194
3 changed files with 11 additions and 4 deletions
+6 -2
View File
@@ -200,14 +200,18 @@ def cli() -> None:
@cli.command(name='sync')
@click.option('--spoof-os', type=click.Choice(['mac', 'win', 'lin']), help='Spoof OS')
@click.option('--spoof-os', type=click.Choice(['auto', 'mac', 'win', 'lin']), help='Spoof OS (auto = native)')
@click.option(
'--spoof-arch', type=click.Choice(['x86_64', 'i686', 'arm64']), help='Spoof architecture'
'--spoof-arch', type=click.Choice(['auto', 'x86_64', 'i686', 'arm64']), help='Spoof architecture (auto = native)'
)
def sync(spoof_os, spoof_arch):
"""
Sync available versions from remote repositories.
"""
if spoof_os == 'auto':
spoof_os = None
if spoof_arch == 'auto':
spoof_arch = None
_do_sync(spoof_os=spoof_os, spoof_arch=spoof_arch)
+2
View File
@@ -608,6 +608,8 @@ def installed_verstr() -> str:
from .multiversion import get_active_path
active = get_active_path()
if active is None:
raise FileNotFoundError("No active version. Please run `camoufox fetch` to install.")
return Version.from_path(active).full_string
+3 -2
View File
@@ -10,6 +10,7 @@ from typing_extensions import Literal
from camoufox.virtdisplay import VirtualDisplay
from .exceptions import InvalidProxy
from .utils import launch_options, sync_attach_vd
@@ -28,8 +29,8 @@ class Camoufox(PlaywrightContextManager):
super().__enter__()
try:
self.browser = NewBrowser(self._playwright, **self.launch_options)
except camoufox.exceptions.InvalidProxy as e:
super().__exit__(camoufox.exceptions.InvalidProxy, e, None)
except InvalidProxy as e:
super().__exit__(InvalidProxy, e, None)
raise
return self.browser