okami.mom/albedo

git clone https://git.nkp.pet/okami.mom/albedo

dawnextensions: add cdp browser tool7de30f7

main
1.4 KiB76 linesraw
1"""Errors expose data rather than requiring agents to parse exception prose."""
2
3from __future__ import annotations
4
5from typing import Any
6
7
8class BrowserError(Exception):
9    kind = "browser_error"
10
11    def __init__(self, message: str, **details: Any) -> None:
12        super().__init__(message)
13        self.details = details
14
15    def to_dict(self) -> dict[str, Any]:
16        return {"kind": self.kind, "message": str(self), **self.details}
17
18
19class ConnectionLost(BrowserError):
20    kind = "connection_lost"
21
22
23class CommandTimeout(BrowserError):
24    kind = "command_timeout"
25
26
27class ProtocolError(BrowserError):
28    kind = "protocol_error"
29
30
31class EventOverflow(BrowserError):
32    kind = "event_overflow"
33
34
35class WaitTimeout(BrowserError):
36    kind = "wait_timeout"
37
38
39class SelectionError(BrowserError):
40    kind = "selection_error"
41
42
43class StaleReference(BrowserError):
44    kind = "stale_reference"
45
46
47class NotActionable(BrowserError):
48    kind = "not_actionable"
49
50
51class ActionOutcomeUnknown(BrowserError):
52    kind = "action_outcome_unknown"
53
54
55class JavaScriptError(BrowserError):
56    kind = "javascript_error"
57
58
59class UnsupportedOperation(BrowserError):
60    kind = "unsupported_operation"
61
62
63class IncompleteObservation(BrowserError):
64    kind = "incomplete_observation"
65
66
67class LaunchError(BrowserError):
68    kind = "launch_error"
69
70
71class TargetGone(BrowserError):
72    kind = "target_gone"
73
74
75class RecoveryError(BrowserError):
76    kind = "recovery_error"