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
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: