API Error Handling
A lightweight, production-ready error handling utility for Express applications.
This component provides:
- Standardized HTTP status codes
- A typed ApiError class
- Consistent, predictable error responses
- Clear separation between operational and programmer errors
Installation Guide
This component requires additional Servercn components.
👉 You do not need to install any Servercn components manually. Running this component installer will automatically install all required components. Manual installation is optional and only recommended if you prefer fine-grained components control
1. Install Servercn components(Optional)
2. Install this component
npx servercn-cli add error-handlerBasic Implementation
MVC: src/utils/api-error.ts
Feature: src/shared/errors/api-error.ts
Usage Example
Error Response
If email or password is missing, then return standardized responses: