exception-handler-lib
v1.0.1
Published
Centralized exception handler for Node.js/TypeScript microservices. Supports service/reason tagging and all common error types.
Downloads
4
Maintainers
Readme
Exception Handler Library
A robust, production-ready exception handler for Node.js/TypeScript microservices.
Features
- Supports all common exception types (auth, validation, not found, etc.)
- Service and reason tagging for error context
- Consistent, plain-English error responses
- Ready for npm publishing and use in all services
Usage
import {
AppException,
handleException,
ExceptionType,
} from "exception-handler-lib";
// Throw an exception
throw new AppException({
type: "ValidationError",
message: "Invalid input",
service: "user-service",
reason: "Missing required field",
});
// In your Express error handler
app.use((err, req, res, next) => {
handleException(res, err);
});