Skip to content

feat: smart error dispatch with inline Browser Bridge diagnosis#481

Merged
jackwener merged 2 commits intomainfrom
feat/smart-error-handling
Mar 26, 2026
Merged

feat: smart error dispatch with inline Browser Bridge diagnosis#481
jackwener merged 2 commits intomainfrom
feat/smart-error-handling

Conversation

@jackwener
Copy link
Copy Markdown
Owner

Summary

  • BrowserConnectError: instead of a static hint, now calls checkDaemonStatus() inline and shows real-time diagnosis with specific fix steps per scenario (daemon down / extension missing / both OK but failed)
  • AuthRequiredError: domain-specific login guidance
  • TimeoutError: shows exact env var override command
  • SelectorError / EmptyResultError: flags adapter as potentially outdated, links to --verbose and issue tracker
  • 164 generic throw new Error() in adapters: pattern-classified into auth / http / not-found / other with tailored guidance per category — previously all fell through to bare Error: xxx
  • BrowserConnectError gains a kind field (daemon-not-running | extension-not-connected | command-failed | unknown) for cleaner dispatch
  • Added 6 new ERROR_ICONS entries (COMMAND_EXEC, ADAPTER_LOAD, NETWORK, API_ERROR, RATE_LIMITED, PAGE_CHANGED, CONFIG)
  • Updated test: invalid bool value is now rejected eagerly in commanderAdapter rather than passed through to execution.ts

Test plan

  • All 337 unit tests pass
  • opencli bilibili hot with extension not installed → shows daemon/extension status + install steps
  • opencli bilibili hot with daemon not running → shows "run again, auto-start" message
  • Any adapter throwing throw new Error('HTTP 403 Hint: Not logged in?') → shows 🔒 + login hint
  • opencli bilibili hot with unknown selector → shows 🔍 + adapter outdated hint + issue link

- BrowserConnectError: runs checkDaemonStatus() on failure, shows real-time
  daemon/extension status and specific fix steps instead of a static hint
- AuthRequiredError: domain-specific login guidance
- TimeoutError: shows exact env var override command
- SelectorError/EmptyResultError: flags adapter as potentially outdated,
  links to debug command and issue tracker
- Generic untyped errors (164 in adapters): pattern-classified into
  auth/http/not-found/other with tailored guidance per category
- BrowserConnectError gains a `kind` field for future dispatch
- Added 6 new error icons (COMMAND_EXEC, ADAPTER_LOAD, NETWORK, etc.)
- Updated test: invalid bool now rejected eagerly in commanderAdapter
- checkDaemonStatus: add { timeout: 300 } to match execution.ts behavior,
  avoids 2s wait on an already-failed path
- catch block: use named _statusErr variable; fall back to kind-derived
  state (running/extensionConnected inferred from BrowserConnectError.kind)
  instead of re-accessing outer err.hint ambiguously
- Extract renderBridgeStatus() helper to share logic between real-time
  and kind-derived fallback paths
- AuthRequiredError: use err.hint when set, respecting adapter-supplied
  hints; fall back to generic domain-based guidance
- HTTP regex: broaden from 'http [45]xx' to also match 'status: 404',
  bare '404', 'status 500', etc. — avoids false negatives
@jackwener jackwener merged commit 40b9237 into main Mar 26, 2026
23 checks passed
@jackwener jackwener deleted the feat/smart-error-handling branch March 26, 2026 19:04
@jackwener jackwener mentioned this pull request Mar 26, 2026
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.

1 participant