feat(cli): friendlier feedback — human error messages, typo suggestions, help examples#63
Merged
Conversation
…ns, help examples - New format/friendlyError.ts: rewrites raw driver/network error signatures (ECONNREFUSED, ENOTFOUND, ETIMEDOUT, dialect-specific auth failures, unknown database) into a one-line cause + suggestion; every error this CLI throws itself passes through unchanged. Swept all 11 call sites (line commands and TUI screens/hooks) that previously did `e instanceof Error ? e.message : String(e)` inline onto this one helper. - commander's showSuggestionAfterError() — a mistyped command now gets a "Did you mean X?" instead of a bare "unknown command" error. - `fox --help` now ends with a handful of copy-pasteable examples.
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
Phase 2 of the CLI UX improvement plan (friendlier feedback), building on Phase 1 (#62):
format/friendlyError.ts: rewrites raw driver/network error signatures (ECONNREFUSED,ENOTFOUND,ETIMEDOUT, Postgres/MySQL/Oracle auth failures, unknown database) into a one-line cause + suggestion (e.g. "Can't reach 127.0.0.1:5432 — is the database running and reachable? Tryfox doctor."). Errors this CLI throws itself (already written to be readable) pass through unchanged. Swept all 11 call sites — line commands and every TUI screen/hook — that previously inlinede instanceof Error ? e.message : String(e).showSuggestionAfterError()—fox comaprenow suggestsDid you mean compare?instead of a bare "unknown command" error.fox --helpnow ends with a handful of copy-pasteable examples (interactive UI, save a connection, compare, dry-run migrate, apply migrate, CI-friendly JSON output).Test plan
cd apps/web && npx tsc --noEmit— cleancd apps/cli && npx tsc --noEmit -p tsconfig.json— cleannpx vitest runfrom repo root — 241 passed, 2 skipped (was 232; +9 new tests coveringfriendlyError's pattern matches and passthrough behavior)fox --helprenders the examples block;fox comapreprintserror: unknown command 'comapre'+(Did you mean compare?)and exits 1.🤖 Generated with Claude Code