Module for error codes used by all entrecode products. By entrecode.
npm i --save ec.errors
// …
const { newError } = require('ec.errors')(myConfig);
// …
function myFunction(input) {
if (input !== 'valid') { // or maybe a little more logic
throw newError(211, 'input', `Input must not be '${input}', only 'valid' is allowed.`);
}
return doSomethingWith(input);
}
myFunction('invalid');
This module has the following configuration options (and their defaults). In order to overwrite with your own config pass an object to the require call.
errorCodeSystemIdentifier: 9,
logging: false,
locale: '',
convertValidationErrorAsArray: false,
- removed
node-config
- switched to module factory style module to support frontend transpilation
- fix: load errorCodes with file extension, should fix webpack build
- feat: adds typings
- fix: fixed error array conversion in mapTV4Error
- initial version published from private module ec.appcms-node-util
- feat: newError(code, detail, verbose) for error creation
- feat: convertValidationError(tv4Result) for mapping tv4 validation errors into entrecode style errors