Skyvern/tests/unit/test_exception_messages.py
Suchintan bc369f530c
Some checks are pending
Run tests and pre-commit / Run tests and pre-commit hooks (push) Waiting to run
Run tests and pre-commit / Frontend Lint and Build (push) Waiting to run
Publish Fern Docs / run (push) Waiting to run
Clean up browser launch failure messaging (#4844)
Co-authored-by: Suchintan Singh <suchintan@skyvern.com>
2026-02-21 23:23:15 -05:00

35 lines
1.3 KiB
Python

from skyvern.exceptions import (
SkyvernException,
UnknownErrorWhileCreatingBrowserContext,
get_user_facing_exception_message,
)
class FakePatchrightTimeoutError(Exception):
pass
def test_unknown_error_while_creating_browser_context_strips_call_log() -> None:
inner_exception = FakePatchrightTimeoutError(
"BrowserType.launch_persistent_context: Timeout 180000ms exceeded. "
"Call log:\n- <launching> /opt/microsoft/msedge/msedge --proxy-server=http://network.joinmassive.com:65534"
)
error = UnknownErrorWhileCreatingBrowserContext("dynamic-browser", inner_exception)
message = str(error)
assert "Call log:" not in message
assert "--proxy-server=" not in message
assert "timed out after 180 seconds" in message
assert "Please try re-running." in message
assert "support@skyvern.com" in message
def test_get_user_facing_exception_message_for_skyvern_exception() -> None:
message = get_user_facing_exception_message(SkyvernException("Human-friendly message"))
assert message == "Human-friendly message"
def test_get_user_facing_exception_message_for_generic_exception() -> None:
message = get_user_facing_exception_message(ValueError("raw error"))
assert message == "Unexpected error: raw error"