Improve API error UX and exit codes #142

Merged
stephen merged 1 commit from feat/134-error-ux-exit-codes into main 2026-06-11 01:35:55 +00:00
Owner

What

Adds friendly central HTTP error headlines for 403/404/429 and stable exit-code classification for API failure classes.

Why

Scripts need reliable failure classes, and users should not see raw /api/v1 paths as the leading error message.

Fixes rasterstate/fj#134

How

  • Adds central context messages in ensure_success while preserving the raw ApiError cause for --debug.
  • Maps ApiError statuses in run_cli to documented stable exit codes.
  • Documents the exit-code contract in docs/exit-codes.md.
  • Keeps command-specific logic untouched.

Test plan

  • cargo fmt --check
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test --all
  • cargo audit --ignore RUSTSEC-2024-0370 -D warnings (not in issue gate)
  • New code has a test

Surface changes

  • Error output for HTTP 403/404/429 now starts with a friendly headline without raw /api/v1 paths.
  • Exit codes are now documented and stable for generic, not-found, auth/forbidden, and rate-limit/transient failures.
  • README.md updated: no command-table change needed.
  • docs/gh-to-fj.md not updated: no gh-equivalence change.

Merge: squash only.

## What Adds friendly central HTTP error headlines for 403/404/429 and stable exit-code classification for API failure classes. ## Why Scripts need reliable failure classes, and users should not see raw `/api/v1` paths as the leading error message. Fixes rasterstate/fj#134 ## How - Adds central context messages in `ensure_success` while preserving the raw `ApiError` cause for `--debug`. - Maps `ApiError` statuses in `run_cli` to documented stable exit codes. - Documents the exit-code contract in `docs/exit-codes.md`. - Keeps command-specific logic untouched. ## Test plan - [x] `cargo fmt --check` - [x] `cargo clippy --all-targets --all-features -- -D warnings` - [x] `cargo test --all` - [ ] `cargo audit --ignore RUSTSEC-2024-0370 -D warnings` (not in issue gate) - [x] New code has a test ## Surface changes - Error output for HTTP 403/404/429 now starts with a friendly headline without raw `/api/v1` paths. - Exit codes are now documented and stable for generic, not-found, auth/forbidden, and rate-limit/transient failures. - README.md updated: no command-table change needed. - docs/gh-to-fj.md not updated: no gh-equivalence change. Merge: squash only.
Improve API error UX and exit codes
All checks were successful
ci / check (pull_request) Successful in 9m48s
ci / coverage (pull_request) Successful in 1m58s
ci / live-e2e (pull_request) Successful in 1m42s
45da7fa27d
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rasterstate/fj!142
No description provided.