Context
The internal/errors package (typed APIError/UserError, HandleHTTPError) is dead code: nothing invokes it, so raw API/HTTP errors reach users unformatted. Error handling style is also split across the command tree, which blocks consistent, structured error output.
Evidence
internal/api/client.go:234 — Client.handleError is a passthrough:
// TODO: Parse HTTP response codes and convert to appropriate errors
// For now, return the error as-is
return err
internal/errors — HandleHTTPError, APIError, and UserError are never invoked anywhere in the codebase.
- Command error style is inconsistent: 96 call sites use
Run + fmt.Fprintf(os.Stderr, ...) + os.Exit(1), while others use RunE. The os.Exit paths skip cobra's error handling entirely.
Suggested fix
- Wire
HandleHTTPError into api.Client.handleError so HTTP status codes map to typed, user-friendly errors (401 → "run cu auth login", 404 → resource context, 429 → rate-limit guidance).
- Migrate commands from
Run+os.Exit to RunE so errors flow through a single formatting point.
This is a prerequisite for the structured JSON error output tracked in #18.
Context
The
internal/errorspackage (typedAPIError/UserError,HandleHTTPError) is dead code: nothing invokes it, so raw API/HTTP errors reach users unformatted. Error handling style is also split across the command tree, which blocks consistent, structured error output.Evidence
internal/api/client.go:234—Client.handleErroris a passthrough:internal/errors—HandleHTTPError,APIError, andUserErrorare never invoked anywhere in the codebase.Run+fmt.Fprintf(os.Stderr, ...)+os.Exit(1), while others useRunE. Theos.Exitpaths skip cobra's error handling entirely.Suggested fix
HandleHTTPErrorintoapi.Client.handleErrorso HTTP status codes map to typed, user-friendly errors (401 → "run cu auth login", 404 → resource context, 429 → rate-limit guidance).Run+os.ExittoRunEso errors flow through a single formatting point.This is a prerequisite for the structured JSON error output tracked in #18.