Skip to content

fix: document or handle intentionally ignored errors #47

@rianjs

Description

@rianjs

Summary

11 instances of silently swallowed errors with _ = or missing checks.

Current State

Examples:

  • internal/gmail/client.go:96 - _ = keychain.MigrateFromFile(tokPath)
  • internal/keychain/keychain.go:105 - defer f.Close() without error check
  • internal/cmd/config/config.go:113-116 - Errors ignored in conditional
  • internal/gmail/client.go:129 - defer func() { _ = f.Close() }()
  • internal/zip/extract.go:151 - _ = fs.Remove(destPath)

Problems

  1. Unclear if errors are intentionally ignored or accidentally missed
  2. Future maintainers may not understand the intent
  3. Could mask real issues

Proposed Solution

For each instance, either:

  1. Add comment explaining why error is intentionally ignored:
// Migration failure is non-fatal - token may not exist
_ = keychain.MigrateFromFile(tokPath)
  1. Log the error at debug level (after logging is added):
if err := keychain.MigrateFromFile(tokPath); err != nil {
    log.Debug("migration skipped", "error", err)
}
  1. Handle the error properly if it matters

Priority

P3 - Code clarity

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