Skip to content

Conform function calls across commands #209

@digitalghost-dev

Description

@digitalghost-dev

The ability, item, and move commands handle API call errors inconsistently:

  • ability.go: Returns err.Error(), err directly, bypassing the output builder
  • item.go: Uses os.Getenv("GO_TESTING") check and os.Exit(1), returns err.Error(), nil (incorrect - nil error signals success)
    • This was left over from a previous version when trying to make tests pass.
  • move.go: Correctly writes error to output builder and returns output.String(), err

This inconsistency causes:

  1. Errors not properly detected by HandleCommandOutput
  2. Error messages printed to stdout instead of stderr
  3. Exit code 0 (success) instead of 1 (failure) for item.go errors
  4. Test-specific code pollution

Standardize all three commands to use the move.go pattern:

xxxStruct, xxxName, err := connections.XxxApiCall(endpoint, xxxName, connections.APIURL)
if err != nil {
   output.WriteString(err.Error())
   return output.String(), err
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorRefactoring existing code.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions