Documentation
¶
Overview ¶
Package result defines chrome-cdp's uniform output envelope and the stable exit-code contract that both humans and the Claude skill depend on.
Index ¶
Constants ¶
const ( ExitOK = 0 // success ExitGeneric = 1 // unclassified error ExitUsage = 2 // bad flags/args, validated before touching Chrome ExitConnection = 3 // can't attach to / launch Chrome ExitTarget = 4 // selector not found, nav/wait timeout, ambiguous/unknown target ExitCDP = 5 // a CDP method returned an error ExitDaemon = 6 // daemon not running / already running / stale lock )
Exit codes are a stable, documented contract (see `chrome-cdp help exit-codes`). error.code strings are finer-grained and map onto these via ExitCodeFor.
const ( CodeGeneric = "generic" CodeUsage = "usage" CodeConnection = "connection_failed" CodeNotDebug = "not_debug_enabled" CodeTargetTimeout = "target_timeout" CodeTargetNotFound = "target_not_found" CodeAmbiguous = "ambiguous_target" CodeNoTarget = "no_current_target" CodeCDP = "cdp_error" CodeDaemon = "daemon_error" )
Stable error.code strings emitted in the envelope's error object. Named so call sites don't scatter bare string literals.
Variables ¶
This section is empty.
Functions ¶
func ExitCodeFor ¶
ExitCodeFor returns the process exit code for an error.code string, defaulting to ExitGeneric for anything unrecognized.
Types ¶
type Envelope ¶
type Envelope struct {
OK bool `json:"ok"`
Command string `json:"command"`
Target *TargetInfo `json:"target,omitempty"`
Result any `json:"result,omitempty"`
Error *Err `json:"error,omitempty"`
ElapsedMs int64 `json:"elapsed_ms"`
}
Envelope is the single JSON shape every command emits under --json.
type Err ¶
Err is a structured command failure with optional context Details.
func (Err) MarshalJSON ¶
MarshalJSON flattens Details into the error object alongside code and message (e.g. {"code","message","selector",...}). encoding/json sorts map keys, so output is deterministic; code and message always win over any Details key.
type ExitCodeDoc ¶
ExitCodeDoc documents one exit code for `chrome-cdp exit-codes`.
func ExitCodes ¶
func ExitCodes() []ExitCodeDoc
ExitCodes is the single source for the documented exit-code contract; the exit-codes command renders it rather than repeating the strings.
type TargetInfo ¶
type TargetInfo struct {
ID string `json:"id"`
Title string `json:"title"`
URL string `json:"url"`
}
TargetInfo identifies the tab a command acted on.