custom-errors-factory
About
Make you errors more handy. Construct them with custom properties and templated messages. Build you own tree of errors inheritance. Use all power of types and best practicies from laguages with strong errors handling experience.
Install
npm install custom-errors-factory
Usage
const errorsFactory = ; const EntityNotFoundError = ; const UserEntityNotFoundError = ; const TestError = ; const EntityNotFoundError = ; const UserEntityNotFoundError = ; const AnotherCustomError = ; const CustomWithInnerError = ; const customError = someProperty: 'some additional property'; console; // trueconsole; // trueconsole; // false
Configuration
You can create custom errors from predefined configuration with inheritance out of box! :)
const errorsFactory = ; // from config object (note: you can use it for async load from remote server, for instance)const context = errorsFactory;
Load custom errors configuration and use it like:
// config/errors.json
// source/errors.jsconst errorsFactory = ;const errorsConfiguration = ; moduleexports = errorsFactory;
// source/app.jsconst EntityNotFound = ; const customError = entityType: 'File' path: '/some-path-to-file';