Skip to content

feat(errors): add structured browser error taxonomy - #283

Open
pt-act wants to merge 1 commit into
citrolabs:devfrom
pt-act:feat/error-taxonomy
Open

feat(errors): add structured browser error taxonomy#283
pt-act wants to merge 1 commit into
citrolabs:devfrom
pt-act:feat/error-taxonomy

Conversation

@pt-act

@pt-act pt-act commented Aug 16, 2026

Copy link
Copy Markdown

Summary

Adds a typed, serializable error taxonomy for browser failures and routes CDP-eval and navigation errors through a single mapper. Each error carries a stable kind/code, a redacted context (URL query/fragment secrets stripped), and a recoveryHint. ElementResolutionError moves into the shared ego-errors.ts so every driver shares one definition. Smallest useful change: purely additive — errors still throw, they are now typed and consistent.

Related issue

No tracked issue — this is the foundation for a small series of reliability/ergonomics improvements to the helper surface (session resilience, lifecycle hooks, semantic actions), each landing as its own focused PR.

Changes

  • src/ego-errors.ts (new) — EgoError base + ElementResolutionError, NavigationTimeoutError, ConnectionLostError, TimeoutError, DialogBlockingError; mapCdpError(raw, ctx) with clear precedence; redactUrl; create*Error factories; toJSON() for serializable, secret-free errors.
  • src/element-resolver.ts, src/driver/locator.ts, src/driver/waits.ts — import ElementResolutionError from ego-errors (moved, single source of truth).
  • src/cdp-eval.ts — drop the duplicate local TimeoutError; typed operation-timeout.
  • src/driver/load.ts, src/driver/nav.ts — throw NavigationTimeoutError on the real timeout path.
  • src/helpers.ts — expose mapCdpError on the helper surface.
  • package/ego-browser/README.md — one Source-layout line documenting ego-errors.ts.

Verification

npm test                      # 316 pass / 0 fail (build + tsc --noEmit + node --test)
npm run validate:site-skills  # site skills ok

Targeted tests cover URL redaction (both message and toJSON), mapCdpError precedence, and the real navigation-timeout path via a fake clock (src/ego-errors.test.mjs, src/driver/nav.test.mjs).

Impact

  • Public helper API or behavior
  • Agent skill or instructions
  • Site learning
  • Installation or update flow
  • Build, CI, or release process
  • Documentation only
  • No externally visible impact

Additive and backward-compatible: no public helper removed; drivers now throw typed errors instead of ad-hoc ones. ElementResolutionError keeps its transient/permanent classification that wait loops rely on. No new runtime dependencies.

Introduce typed, serializable errors for element resolution, navigation timeouts, connection loss, dialogs, and operation timeouts. Route CDP evaluation and navigation failures through shared mapping and redact sensitive URL components.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants