Getting Started
Unified Errors Handler is an advanced error-handling library for Node.js. It standardizes error structures across Express.js, NestJS, and databases like MySQL, PostgreSQL, and MongoDB. It simplifies debugging, improves consistency, and enhances error logging.
Installation
$ npm install unified-errors-handler
Unified Structure
All errors will be mapped to this structure, and that make errors:
- Consistent Format – A clear and structured response for errors.
- Support for Multiple Errors – The array allows multiple validation errors at once.
- Extensibility – The details object lets you provide extra information.
{
errors: [{
fields: ['name', 'password'], // optional
code: 'YOUR_CODE',
message: 'your message'
details: { // optional - more details about error
key: value
}
}]
}