Skip to content

Conversation

@0x80
Copy link
Owner

@0x80 0x80 commented Jun 20, 2025

PR Summary: Maintain v1 Compatibility with Optional Enhanced Error Handling

Overview

Reversed the API design to maintain full v1 compatibility while providing enhanced error handling as an opt-in feature.

Key Changes

1. Maintained v1 Compatibility

  • Default behavior: Functions throw errors immediately on first failure (unchanged from v1)
  • No breaking changes: Existing code continues to work without modification

2. Introduced noThrow Option

  • New option: noThrow?: boolean (default: false)
  • When false (default): Throws errors immediately (v1 behavior)
  • When true: Returns discriminated union with error collection

3. Function Overloads for Type Safety

// Enhanced error handling (opt-in)
processInChunks(items, fn, { noThrow: true }): Promise<ProcessResult<R>>

// Default throwing behavior (v1 compatible)  
processInChunks(items, fn): Promise<R[]>

4. Updated Documentation

  • Removed migration section: No longer needed since API remains compatible
  • Default examples: Show v1 throwing behavior
  • Enhanced section: Demonstrates noThrow: true usage for error collection

Benefits

  • Zero breaking changes: v1 code works unchanged
  • Enhanced error handling: Available when needed via noThrow: true
  • Type safety: Overloads ensure correct return types
  • Clear intent: noThrow option name is self-documenting

This approach provides enhanced error handling capabilities while maintaining complete backward compatibility with v1.

@0x80 0x80 changed the title Do not throw by default Add noThrow option to return partial results Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants