A lightweight, TypeScript-friendly HTTP exception class for Node.js and Express applications. Provides consistent error handling with automatic status categorization and operational error tracking.
- 🚀 Simple & Lightweight - Minimal footprint with zero dependencies
- 📦 TypeScript Support - Full type definitions included
- 🔍 Automatic Status Categorization - Automatically sets
failfor 4xx errors anderrorfor 5xx errors - 🛡️ Operational Error Flag - Distinguish between operational and programming errors
- 🎯 Express-Ready - Designed to work seamlessly with Express error handlers
- 📝 Stack Trace Support - Preserves stack traces for easier debugging
npm install express-http-exceptionimport { HTTPException } from 'express-http-exception';
// Throw HTTP errors
throw new HTTPException('User not found', 404);
throw new HTTPException('Bad request', 400);
throw new HTTPException('Server error', 500);