Skip to content

refactor: make MarkTaskDone and similar functions return errors #16

@LudoLoops

Description

@LudoLoops

Issue

Functions like MarkTaskDone, MarkTaskInProgress print errors directly instead of returning them.

func MarkTaskDone(cfg config.Config, taskTitle string) {  // ← Returns void
    // ...
    if foundTask == nil {
        fmt.Printf("Task '%s' not found.\n", taskTitle)  // Prints directly
        return
    }
    // ...
}

Problem

  • Caller cannot tell if operation succeeded
  • Error messages go to stdout, not stderr
  • Caller cannot make decisions based on success/failure
  • Inconsistent with Go error handling patterns

Solution

Change signatures to return error:

func MarkTaskDone(cfg config.Config, taskTitle string) error {
    // ...
    if foundTask == nil {
        return fmt.Errorf("task not found: %s", taskTitle)
    }
    // ...
    return nil
}

Update all callers to check errors.

Affected Functions

  • MarkTaskDone
  • MarkTaskInProgress
  • MarkTaskInProgressByTitle

Benefits

  • Proper Go error handling
  • Caller has control over error messages
  • Enables better error handling in CLI

Impact

🟡 Medium - Requires caller updates

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions