Skip to content

🏷️ v1.0.0 β€” Initial release

Choose a tag to compare

@twinedo twinedo released this 23 Dec 05:09
· 8 commits to main since this release

✨ What this is

@twinedo/app-error is a small, framework-agnostic library that normalizes
errors from fetch, axios-like clients, and unknown runtime errors into a single, predictable AppError model.

It’s designed for projects where:

  • Different backends return different error shapes
  • HTTP clients behave differently
  • Teams want consistent UI messaging, retry logic, and logging inputs

πŸ“¦ Included in this release

Core API

  • toAppError(error, policy?)
    Normalize any thrown value into a predictable AppError

  • fromFetch(response, body?, policy?)
    Convert non-OK fetch responses into AppError

  • defineErrorPolicy(config)
    Configure backend-specific error extraction rules

  • isAppError(value)
    Type guard for normalized errors

  • errorKey(error)
    Stable fingerprint for deduping and logging

  • isRetryable(error)
    Centralized retry decision helper

  • attempt(fn)
    Safe execution helper returning { ok, data | error }

βœ… Guarantees

This release guarantees that:

  • Normalization never throws
  • Output shape is always predictable
  • message is always safe to display in UI
  • Original errors are preserved via cause
  • No input error is mutated
  • Fully TypeScript-friendly
  • Framework-agnostic (React, React Native, Vue, Angular, Node)

🚫 Non-Goals

This library intentionally does not:

  • Perform logging, reporting, or analytics
  • Display UI or toast notifications
  • Guess backend-specific error schemas
  • Replace HTTP clients like fetch or axios
  • Enforce localization or translations
  • Hide or swallow errors silently

🚦 Status

This is an initial release (v0.1.0).

  • The public API is intentionally small and stable
  • Feedback and real-world use cases are welcome before moving toward v1.0

πŸ”— Links

πŸ™ Thank you

Thanks for checking out the project!
If you find issues or have suggestions, please open an issue or discussion.