affaan-m/ECC · error

user

Error message

user %s: %w

What it means

Go error-wrapping exemplar: fmt.Errorf with %w attaches the entity id to a sentinel (here ErrNotFound mapped from sql.ErrNoRows) so the chain preserves both context and the comparable sentinel via errors.Is.

Solutions

  1. Review the constraint in the error message, correct the input accordingly, and re-run.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Triggered when SKILL.md rejects the current invocation: user <value>: <err>

Common situations: Occurs while running skills/error-handling/SKILL.md with invalid arguments, missing flags, or a failing external dependency; the guard at skills/error-handling/SKILL.md:274 aborts the command with this message.


AI-assisted analysis of affaan-m/ECC@06c5e118c4 (2026-08-18). Data as JSON: /api/errors/4ab1406535543e11. Report an issue: GitHub.

Appendix: source

Thrown at skills/error-handling/SKILL.md:274

### Sentinel Errors and Error Wrapping

```go
package domain

import "errors"

// Sentinel errors for type-checking
var (
    ErrNotFound    = errors.New("not found")
    ErrUnauthorized = errors.New("unauthorized")
    ErrConflict     = errors.New("conflict")
)

// Wrap errors with context — never lose the original
func (r *UserRepository) FindByID(ctx context.Context, id string) (*User, error) {
    user, err := r.db.QueryRow(ctx, "SELECT * FROM users WHERE id = $1", id)
    if errors.Is(err, sql.ErrNoRows) {
        return nil, fmt.Errorf("user %s: %w", id, ErrNotFound)
    }
    if err != nil {
        return nil, fmt.Errorf("querying user %s: %w", id, err)
    }
    return user, nil
}

// At the handler level, unwrap to determine response
func (h *Handler) GetUser(w http.ResponseWriter, r *http.Request) {
    user, err := h.service.GetUser(r.Context(), chi.URLParam(r, "id"))
    if err != nil {
        switch {
        case errors.Is(err, domain.ErrNotFound):
            writeError(w, http.StatusNotFound, "not_found", err.Error())
        case errors.Is(err, domain.ErrUnauthorized):
            writeError(w, http.StatusForbidden, "forbidden", "Access denied")
        default:
            slog.Error("unexpected error", "err", err)

View on GitHub (pinned to 06c5e118c4)