Inherify
Inherify is a function constructor to make easy and clean inherits prototypes.
Installation
Install with npm install inherify --save
.
Usage
To use, add the require
node module:
const Inherify = require('inherify'); const CustomError = Inherify(Error, { __constructor: function(settings) { settings = typeof(settings) === 'string' ? { message: settings } : settings || {}; this.name = 'CustomError'; this.type = settings.type || 'Application'; this.message = settings.message || 'An error occurred.'; this.detail = settings.detail || ''; this.extendedInfo = settings.extendedInfo || ''; this.errorCode = settings.errorCode || ''; Error.captureStackTrace(this, CustomError); } }); throw new CustomError('Custom error raised!');