npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@orchard9ai/error-handling

v0.1.2

Published

Federated error handling package with go-core-http-toolkit format support and logging integration

Readme

@orchard9ai/error-handling

Graceful HTTP error handling for React applications. Prevents crashes from API errors and provides user-friendly error messages.

Installation

npm install @orchard9ai/error-handling

Quick Start

import { useHttpClient, ToastProvider, installGlobalErrorHandling } from '@orchard9ai/error-handling';

// 1. Wrap your app with ToastProvider
function App() {
  return (
    <ToastProvider>
      <YourApp />
    </ToastProvider>
  );
}

// 2. Use the HTTP client in components
function MyComponent() {
  const http = useHttpClient({
    baseUrl: 'http://localhost:25820/api/v1'
  });

  const handleSubmit = async (data) => {
    try {
      const result = await http.post('/organizations/register', data);
      console.log('Success:', result.data);
    } catch (error) {
      // Error automatically shown as toast
      // No app crashes!
    }
  };
}

Key Features

  • No More Crashes: 409 conflicts and other HTTP errors show friendly toasts instead of crashing
  • Auto Cleanup: Requests automatically abort when components unmount
  • XSS Safe: All error messages are sanitized
  • React Ready: Hooks for easy integration

API Reference

useHttpClient(config)

React hook that creates an HTTP client with automatic cleanup.

const http = useHttpClient({
  baseUrl: 'https://api.example.com',
  timeout: 30000,
  enableRetry: false, // Default: false
  showToasts: true,   // Default: true
});

// Make requests
const response = await http.get('/users');
const response = await http.post('/users', { name: 'John' });
const response = await http.put('/users/1', { name: 'Jane' });
const response = await http.delete('/users/1');

ToastProvider

Required wrapper component for toast notifications.

<ToastProvider config={{
  position: 'top-right',
  autoHideDuration: 5000
}}>
  <App />
</ToastProvider>

installGlobalErrorHandling(config)

Optional: Catch unhandled errors globally.

installGlobalErrorHandling({
  showToasts: true,
  logToConsole: true,
  ignoredErrors: ['ResizeObserver loop limit exceeded']
});

Error Format

Automatically handles API errors in this format:

{
  "error": "conflict",
  "message": "Organization already exists",
  "code": "organization_conflict",
  "correlation_id": "err_9c20308c",
  "details": {
    "field": "name",
    "value": "Already exists"
  }
}

Best Practices

  1. Always use useHttpClient for HTTP requests (not raw fetch)
  2. Wrap your app with ToastProvider
  3. Let errors bubble up - they'll be shown as toasts automatically
  4. Don't enable retry unless you have specific backoff requirements
  5. Configure base URL once and reuse the client

Security

  • All error messages are HTML-escaped to prevent XSS
  • Sensitive fields (password, token, api_key) are automatically filtered
  • Stack traces are never shown to users

License

MIT