make the error object with custom defines
npm i @open-node/errors --save
- your node.js process code
const Errors = require('@open-node/errors'); const defines = [ ['yourErrorCode', 'Your error message, allow add variable, eg: %s'] ['yourErrorCode2', 'Your error message, allow add variable, eg: %s, %d'] ]; const errors = Errors(defines); // usage in your code try { ... ... } catch (e) { const error = errors.yourErrorCode(e.message); // returns error be instanceOf Error writeErrorLog(error); }