mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-07-31 09:46:05 -04:00
pip-installable Python API driving the bundled binary over MCP HTTP: Browser/Session with one generated method per browser tool (lightpanda/_methods.py, regenerated from tools/list), run_script() replay, a CLI trampoline entry point, pytest suite against local fixtures, and pdoc docs generation.
25 lines
759 B
Python
25 lines
759 B
Python
class LightpandaError(Exception):
|
|
"""Base error for the lightpanda package."""
|
|
|
|
|
|
class ProtocolError(LightpandaError):
|
|
"""JSON-RPC level failure (invalid request, timeout, internal error)."""
|
|
|
|
def __init__(self, message: str, code: int | None = None):
|
|
super().__init__(message)
|
|
self.code = code
|
|
|
|
|
|
class ToolError(LightpandaError):
|
|
"""A browser tool reported failure (bad selector, JS exception, ...)."""
|
|
|
|
|
|
class ScriptError(LightpandaError):
|
|
"""A script replay (`run_script`) exited with a failure."""
|
|
|
|
def __init__(self, message: str, returncode: int, stdout: str = "", stderr: str = ""):
|
|
super().__init__(message)
|
|
self.returncode = returncode
|
|
self.stdout = stdout
|
|
self.stderr = stderr
|