Skip to content

Improve error handling in flags.LatestFlag() #198

@digitalghost-dev

Description

@digitalghost-dev

The flags.LatestFlag() function currently always returns nil for errors, even when operations fail (network errors, JSON parsing errors, etc.). This means:

  • The CLI always exits with code 0 (success), even on failure
  • Callers have no way to distinguish between success and failure
  • Error messages are printed, but the program reports success

Solution

Refactor flags.LatestRelease() to return errors properly:

  1. Change function signature: func latestRelease(output *strings.Builder) error
  2. Return actual errors for all failure cases (URL parsing, HTTP requests, JSON unmarshaling, etc.)
  3. Update flags.LatestFlag() to propagate the error: return result, err
  4. Update CLI to exit with code 1 when error occurs

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorRefactoring existing code.

    Projects

    Status
    Completed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions