index.js
function create(name, parent, defmessage, abstract, construct) {
    if (typeof name === "object") {
        return create(name.name, name.parent, name.defmessage, name.abstract, name.construct);
    }
    parent = parent || global.Error;
    if ((defmessage === null) || (defmessage === undefined)) {
        if (parent.ce && parent.ce.hasOwnProperty("defmessage")) {
            defmessage = parent.ce.defmessage;
        }
    }
    if (typeof construct !== "function") {
        if (parent.ce && (typeof parent.ce.construct === "function")) {
            construct = parent.ce.construct;
        } else {
            construct = null;
        }
    }
    function CustomError(message) {
        Error.call(this);
        Error.captureStackTrace(this, CustomError);
        if (abstract) {
            throw new AbstractError(name);
        }
        if (construct) {
            construct.apply(this, arguments);
        } else {
            if ((message !== undefined) && (message !== null)) {
                this.message = message;
            }
        }
    }
    CustomError.prototype = Object.create(parent.prototype);
    CustomError.prototype.constructor = CustomError;
    CustomError.prototype.name = name;
    CustomError.prototype.message = defmessage;
    CustomError.prototype.parent = helpers.parent;
    CustomError.ce = {
        parent: parent,
        defmessage: defmessage,
        construct: construct
    };
    CustomError.inherit = helpers.inherit;
    CustomError.toString = function () {
        return "[Error class " + name + "]";
    };
    CustomError.init = function init() {
        return call.apply(construct, slice.call(arguments));
    };
    return CustomError;
}
function create(name, parent, defmessage, abstract, construct) {
    if (typeof name === "object") {
        return create(name.name, name.parent, name.defmessage, name.abstract, name.construct);
    }
    parent = parent || global.Error;
    if ((defmessage === null) || (defmessage === undefined)) {
        if (parent.ce && parent.ce.hasOwnProperty("defmessage")) {
            defmessage = parent.ce.defmessage;
        }
    }
    if (typeof construct !== "function") {
        if (parent.ce && (typeof parent.ce.construct === "function")) {
            construct = parent.ce.construct;
        } else {
            construct = null;
        }
    }
    function CustomError(message) {
        Error.call(this);
        Error.captureStackTrace(this, CustomError);
        if (abstract) {
            throw new AbstractError(name);
        }
        if (construct) {
            construct.apply(this, arguments);
        } else {
            if ((message !== undefined) && (message !== null)) {
                this.message = message;
            }
        }
    }
    CustomError.prototype = Object.create(parent.prototype);
    CustomError.prototype.constructor = CustomError;
    CustomError.prototype.name = name;
    CustomError.prototype.message = defmessage;
    CustomError.prototype.parent = helpers.parent;
    CustomError.ce = {
        parent: parent,
        defmessage: defmessage,
        construct: construct
    };
    CustomError.inherit = helpers.inherit;
    CustomError.toString = function () {
        return "[Error class " + name + "]";
    };
    CustomError.init = function init() {
        return call.apply(construct, slice.call(arguments));
    };
    return CustomError;
}
function create ( name , parent , defmessage , abstract , construct ) { if ( typeof name === "object" ) { return create ( name . name , name . parent , name . defmessage , name . abstract , name . construct ) ; } parent = parent || global . Error ; if ( ( defmessage === null ) || ( defmessage === undefined ) ) { if ( parent . ce && parent . ce . hasOwnProperty ( "defmessage" ) ) { defmessage = parent . ce . defmessage ; } } if ( typeof construct !== "function" ) { if ( parent . ce && ( typeof parent . ce . construct === "function" ) ) { construct = parent . ce . construct ; } else { construct = null ; } } function CustomError ( message ) { Error . call ( this ) ; Error . captureStackTrace ( this , CustomError ) ; if ( abstract ) { throw new AbstractError ( name ) ; } if ( construct ) { construct . apply ( this , arguments ) ; } else { if ( ( message !== undefined ) && ( message !== null ) ) { this . message = message ; } } } CustomError . prototype = Object . create ( parent . prototype ) ; CustomError . prototype . constructor = CustomError ; CustomError . prototype . name = name ; CustomError . prototype . message = defmessage ; CustomError . prototype . parent = helpers . parent ; CustomError . ce = { parent : parent , defmessage : defmessage , construct : construct } ; CustomError . inherit = helpers . inherit ; CustomError . toString = function ( ) { return "[Error class " + name + "]" ; } ; CustomError . init = function init ( ) { return call . apply ( construct , slice . call ( arguments ) ) ; } ; return CustomError ; }
Create a custom error class

@param {(String|Object)} name
the name of exception (or dictionary of arguments)
@param {Function} [parent]
the parent exception class (constructor) (Error by default)
@param {String} [defmessage]
the default message
@param {Boolean} [abstract]
the flag of an abstract class
@param {Function} [construct]
the custom constructor for this class
@return {Function}
the constructor of custom error
Create a custom error class