Skip to content

feat: Add structured error formatting with codes and hints #12

@gnapse

Description

@gnapse

Summary

Improve error messages with structured formatting including error codes and actionable hints.

Details

Add a formatError() function following todoist-cli pattern:

export function formatError(code: string, message: string, hints?: string[]): string {
    const lines = [\`Error: \${code}\`, message]
    if (hints && hints.length > 0) {
        lines.push('')
        for (const hint of hints) {
            lines.push(\`  - \${hint}\`)
        }
    }
    return chalk.red(lines.join('\n'))
}

Example Output

Error: AMBIGUOUS_DOCUMENT
Multiple documents match "Guide":
  - "User Guide" (id:abc123)
  - "Developer Guide" (id:def456)

Effort

1 day

Reference

Based on todoist-cli pattern in src/lib/output.ts:335-344

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions