Skip to content

Add error wrapping examples to documentation #46

@fogfish

Description

@fogfish

Problem: Users may not know how to add context to thinker errors.

Required Changes:

  1. Add section to README.md about error handling
  2. Show how to use errors.Unwrap() with thinker errors
  3. Document all error types in errors.go
  4. Add example showing error chain inspection

Content to Add:

### Error Handling

The library uses typed errors from `github.com/fogfish/faults`:

```go
// Check error type
if errors.Is(err, thinker.ErrAborted) {
    // Handle abortion
}

// Add context
return thinker.ErrLLM.With(err, "failed to process prompt")

// Unwrap error chain
cause := errors.Unwrap(err)

Common Errors:

  • ErrCodec: Encoder/Decoder failed
  • ErrLLM: LLM communication failed
  • ErrAborted: Agent aborted execution
  • ErrMaxEpoch: Maximum iterations reached
  • ErrCmd: Tool/command execution failed

Estimated Effort: 45 minutes
Skills Required: Technical writing, error handling

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions