feat(errors): add structured browser error taxonomy - #283
Open
pt-act wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 redactedcontext(URL query/fragment secrets stripped), and arecoveryHint.ElementResolutionErrormoves into the sharedego-errors.tsso 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) —EgoErrorbase +ElementResolutionError,NavigationTimeoutError,ConnectionLostError,TimeoutError,DialogBlockingError;mapCdpError(raw, ctx)with clear precedence;redactUrl;create*Errorfactories;toJSON()for serializable, secret-free errors.src/element-resolver.ts,src/driver/locator.ts,src/driver/waits.ts— importElementResolutionErrorfromego-errors(moved, single source of truth).src/cdp-eval.ts— drop the duplicate localTimeoutError; typed operation-timeout.src/driver/load.ts,src/driver/nav.ts— throwNavigationTimeoutErroron the real timeout path.src/helpers.ts— exposemapCdpErroron the helper surface.package/ego-browser/README.md— one Source-layout line documentingego-errors.ts.Verification
Targeted tests cover URL redaction (both
messageandtoJSON),mapCdpErrorprecedence, and the real navigation-timeout path via a fake clock (src/ego-errors.test.mjs,src/driver/nav.test.mjs).Impact
Additive and backward-compatible: no public helper removed; drivers now throw typed errors instead of ad-hoc ones.
ElementResolutionErrorkeeps itstransient/permanentclassification that wait loops rely on. No new runtime dependencies.